trunk/src/osd/windows/winfile.c
| r242805 | r242806 | |
| 22 | 22 | #include "winutil.h" |
| 23 | 23 | #include "winutf8.h" |
| 24 | 24 | |
| 25 | | #if defined(SDLMAME_WIN32) || defined(SDLMAME_OS2) |
| 26 | | #define INVPATHSEPCH '/' |
| 27 | | #else |
| 28 | | #define INVPATHSEPCH '\\' |
| 29 | | #endif |
| 30 | | |
| 31 | 25 | #include "winfile.h" |
| 32 | 26 | |
| 33 | 27 | //============================================================ |
| r242805 | r242806 | |
| 96 | 90 | |
| 97 | 91 | // convert the path into something Windows compatible |
| 98 | 92 | dst = (*file)->filename; |
| 93 | #if defined(SDLMAME_WIN32) || defined(SDLMAME_OS2) |
| 99 | 94 | for (src = t_path; *src != 0; src++) |
| 95 | *dst++ = (*src == '/') ? '\\' : *src; |
| 96 | #else |
| 97 | for (src = t_path; *src != 0; src++) |
| 100 | 98 | *dst++ = *src;//(*src == '/') ? '\\' : *src; |
| 99 | #endif |
| 101 | 100 | *dst++ = 0; |
| 102 | 101 | |
| 103 | 102 | // select the file open modes |
| r242805 | r242806 | |
| 127 | 126 | // create the path if necessary |
| 128 | 127 | if (error == ERROR_PATH_NOT_FOUND && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS)) |
| 129 | 128 | { |
| 130 | | TCHAR *pathsep = _tcsrchr((*file)->filename, INVPATHSEPCH); |
| 129 | TCHAR *pathsep = _tcsrchr((*file)->filename, '\\'); |
| 131 | 130 | if (pathsep != NULL) |
| 132 | 131 | { |
| 133 | 132 | // create the path up to the file |
| 134 | 133 | *pathsep = 0; |
| 135 | 134 | error = create_path_recursive((*file)->filename); |
| 136 | | *pathsep = INVPATHSEPCH; |
| 135 | *pathsep = '\\'; |
| 137 | 136 | |
| 138 | 137 | // attempt to reopen the file |
| 139 | 138 | if (error == NO_ERROR) |
| r242805 | r242806 | |
| 406 | 405 | |
| 407 | 406 | DWORD create_path_recursive(const TCHAR *path) |
| 408 | 407 | { |
| 409 | | TCHAR *sep = (TCHAR *)_tcsrchr(path, INVPATHSEPCH); |
| 408 | TCHAR *sep = (TCHAR *)_tcsrchr(path, '\\'); |
| 410 | 409 | |
| 411 | 410 | // if there's still a separator, and it's not the root, nuke it and recurse |
| 412 | | if (sep != NULL && sep > path && sep[0] != ':' && sep[-1] != INVPATHSEPCH) |
| 411 | if (sep != NULL && sep > path && sep[0] != ':' && sep[-1] != '\\') |
| 413 | 412 | { |
| 414 | 413 | *sep = 0; |
| 415 | 414 | create_path_recursive(path); |
| 416 | | *sep = INVPATHSEPCH; |
| 415 | *sep = '\\'; |
| 417 | 416 | } |
| 418 | 417 | |
| 419 | 418 | // if the path already exists, we're done |