src/mess/zippath.c
| r3044 | r3045 | |
| 179 | 179 | |
| 180 | 180 | |
| 181 | 181 | /*------------------------------------------------- |
| 182 | | is_zip_separator - special check for path |
| 183 | | separators |
| 182 | is_zip_file_separator - returns whether this |
| 183 | character is a path separator within a ZIP file |
| 184 | 184 | -------------------------------------------------*/ |
| 185 | 185 | |
| 186 | | static int is_zip_separator(char c) |
| 186 | static int is_zip_file_separator(char c) |
| 187 | 187 | { |
| 188 | | return (c == '/') || osd_is_path_separator(c); |
| 188 | return (c == '/') || (c == '\\'); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
| 192 | 192 | |
| 193 | 193 | /*------------------------------------------------- |
| 194 | is_zip_path_separator - returns whether this |
| 195 | character is a path separator within a ZIP path |
| 196 | -------------------------------------------------*/ |
| 197 | |
| 198 | static int is_zip_path_separator(char c) |
| 199 | { |
| 200 | return is_zip_file_separator(c) || osd_is_path_separator(c); |
| 201 | } |
| 202 | |
| 203 | |
| 204 | |
| 205 | /*------------------------------------------------- |
| 194 | 206 | zippath_find_sub_path - attempts to identify the |
| 195 | 207 | type of a sub path in a zip file |
| 196 | 208 | -------------------------------------------------*/ |
| r3044 | r3045 | |
| 214 | 226 | j = 0; |
| 215 | 227 | do |
| 216 | 228 | { |
| 217 | | while(header->filename[i] == '/') |
| 229 | while(is_zip_file_separator(header->filename[i])) |
| 218 | 230 | i++; |
| 219 | | while(is_zip_separator(subpath[j])) |
| 231 | while(is_zip_path_separator(subpath[j])) |
| 220 | 232 | j++; |
| 221 | 233 | while((header->filename[i] != '\0') && (tolower(header->filename[i]) == tolower(subpath[j]))) |
| 222 | 234 | { |
| r3044 | r3045 | |
| 224 | 236 | j++; |
| 225 | 237 | } |
| 226 | 238 | } |
| 227 | | while((header->filename[i] == '/') && is_zip_separator(subpath[j])); |
| 239 | while(is_zip_file_separator(header->filename[i]) && is_zip_path_separator(subpath[j])); |
| 228 | 240 | |
| 229 | 241 | if (subpath[j] == '\0') |
| 230 | 242 | { |
| r3044 | r3045 | |
| 234 | 246 | *type = ENTTYPE_FILE; |
| 235 | 247 | return header; |
| 236 | 248 | } |
| 237 | | else if ((i == 0) || (header->filename[i] == '/')) |
| 249 | else if ((i == 0) || is_zip_file_separator(header->filename[i])) |
| 238 | 250 | { |
| 239 | 251 | if (type != NULL) |
| 240 | 252 | *type = ENTTYPE_DIR; |
| r3044 | r3045 | |
| 459 | 471 | && !strncmp(astring_c(directory->zipprefix), header->filename, len)) |
| 460 | 472 | { |
| 461 | 473 | result = &header->filename[len]; |
| 462 | | while(*result == '/') |
| 474 | while(is_zip_file_separator(*result)) |
| 463 | 475 | result++; |
| 464 | 476 | } |
| 465 | 477 | |
| r3044 | r3045 | |
| 477 | 489 | const zip_file_header *header; |
| 478 | 490 | const char *relpath; |
| 479 | 491 | const char *separator; |
| 492 | const char *s; |
| 480 | 493 | zippath_returned_directory *rdent; |
| 481 | 494 | |
| 482 | 495 | if (!directory->returned_parent) |
| r3044 | r3045 | |
| 525 | 538 | if (relpath != NULL) |
| 526 | 539 | { |
| 527 | 540 | /* we've found a ZIP entry; but this may be an entry deep within the target directory */ |
| 528 | | separator = strchr(relpath, '/'); |
| 541 | for (s = relpath; *s && !is_zip_file_separator(*s); s++) |
| 542 | ; |
| 543 | separator = *s ? s : NULL; |
| 544 | |
| 529 | 545 | if (separator != NULL) |
| 530 | 546 | { |
| 531 | 547 | /* a nested entry; loop through returned_dirlist to see if we've returned the parent directory */ |