Changeset 133 for smplayer/vendor/current/zlib/gzlib.c
- Timestamp:
- Oct 24, 2012, 7:56:20 PM (13 years ago)
- Location:
- smplayer/vendor/current/zlib
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
smplayer/vendor/current/zlib/gzlib.c
r121 r133 1 1 /* gzlib.c -- zlib functions common to reading and writing gzip files 2 * Copyright (C) 2004, 2010, 2011 Mark Adler2 * Copyright (C) 2004, 2010, 2011, 2012 Mark Adler 3 3 * For conditions of distribution and use, see copyright notice in zlib.h 4 4 */ … … 18 18 /* Local functions */ 19 19 local void gz_reset OF((gz_statep)); 20 local gzFile gz_open OF((const char*, int, const char *));20 local gzFile gz_open OF((const void *, int, const char *)); 21 21 22 22 #if defined UNDER_CE … … 90 90 /* Open a gzip file either by name or file descriptor. */ 91 91 local gzFile gz_open(path, fd, mode) 92 const char*path;92 const void *path; 93 93 int fd; 94 94 const char *mode; 95 95 { 96 96 gz_statep state; 97 size_t len; 98 int oflag; 99 #ifdef O_CLOEXEC 100 int cloexec = 0; 101 #endif 102 #ifdef O_EXCL 103 int exclusive = 0; 104 #endif 97 105 98 106 /* check input */ … … 134 142 case 'b': /* ignore -- will request binary anyway */ 135 143 break; 144 #ifdef O_CLOEXEC 145 case 'e': 146 cloexec = 1; 147 break; 148 #endif 149 #ifdef O_EXCL 150 case 'x': 151 exclusive = 1; 152 break; 153 #endif 136 154 case 'f': 137 155 state->strategy = Z_FILTERED; … … 169 187 170 188 /* save the path name for error messages */ 171 state->path = malloc(strlen(path) + 1); 189 #ifdef _WIN32 190 if (fd == -2) { 191 len = wcstombs(NULL, path, 0); 192 if (len == (size_t)-1) 193 len = 0; 194 } 195 else 196 #endif 197 len = strlen(path); 198 state->path = malloc(len + 1); 172 199 if (state->path == NULL) { 173 200 free(state); 174 201 return NULL; 175 202 } 176 strcpy(state->path, path); 177 178 /* open the file with the appropriate mode (or just use fd) */ 179 state->fd = fd != -1 ? fd : 180 open(path, 203 #ifdef _WIN32 204 if (fd == -2) 205 if (len) 206 wcstombs(state->path, path, len + 1); 207 else 208 *(state->path) = 0; 209 else 210 #endif 211 strcpy(state->path, path); 212 213 /* compute the flags for open() */ 214 oflag = 181 215 #ifdef O_LARGEFILE 182 216 O_LARGEFILE | 183 217 #endif 184 218 #ifdef O_BINARY 185 O_BINARY | 186 #endif 187 (state->mode == GZ_READ ? 188 O_RDONLY : 189 (O_WRONLY | O_CREAT | ( 190 state->mode == GZ_WRITE ? 191 O_TRUNC : 192 O_APPEND))), 193 0666); 219 O_BINARY | 220 #endif 221 #ifdef O_CLOEXEC 222 (cloexec ? O_CLOEXEC : 0) | 223 #endif 224 (state->mode == GZ_READ ? 225 O_RDONLY : 226 (O_WRONLY | O_CREAT | 227 #ifdef O_EXCL 228 (exclusive ? O_EXCL : 0) | 229 #endif 230 (state->mode == GZ_WRITE ? 231 O_TRUNC : 232 O_APPEND))); 233 234 /* open the file with the appropriate flags (or just use fd) */ 235 state->fd = fd > -1 ? fd : ( 236 #ifdef _WIN32 237 fd == -2 ? _wopen(path, oflag, 0666) : 238 #endif 239 open(path, oflag, 0666)); 194 240 if (state->fd == -1) { 195 241 free(state->path); … … 244 290 return gz; 245 291 } 292 293 /* -- see zlib.h -- */ 294 #ifdef _WIN32 295 gzFile ZEXPORT gzopen_w(path, mode) 296 const wchar_t *path; 297 const char *mode; 298 { 299 return gz_open(path, -2, mode); 300 } 301 #endif 246 302 247 303 /* -- see zlib.h -- */
Note:
See TracChangeset
for help on using the changeset viewer.