trunk/src/osd/windows/winfile.c
| r242803 | r242804 | |
| 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 | |
| 25 | 31 | #include "winfile.h" |
| 26 | 32 | |
| 27 | 33 | //============================================================ |
| r242803 | r242804 | |
| 118 | 124 | if ((*file)->handle == INVALID_HANDLE_VALUE) |
| 119 | 125 | { |
| 120 | 126 | DWORD error = GetLastError(); |
| 121 | | |
| 122 | 127 | // create the path if necessary |
| 123 | 128 | if (error == ERROR_PATH_NOT_FOUND && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS)) |
| 124 | 129 | { |
| 125 | | TCHAR *pathsep = _tcsrchr((*file)->filename, '\\'); |
| 130 | TCHAR *pathsep = _tcsrchr((*file)->filename, INVPATHSEPCH); |
| 126 | 131 | if (pathsep != NULL) |
| 127 | 132 | { |
| 128 | 133 | // create the path up to the file |
| 129 | 134 | *pathsep = 0; |
| 130 | 135 | error = create_path_recursive((*file)->filename); |
| 131 | | *pathsep = '\\'; |
| 136 | *pathsep = INVPATHSEPCH; |
| 132 | 137 | |
| 133 | 138 | // attempt to reopen the file |
| 134 | 139 | if (error == NO_ERROR) |
| r242803 | r242804 | |
| 401 | 406 | |
| 402 | 407 | DWORD create_path_recursive(const TCHAR *path) |
| 403 | 408 | { |
| 404 | | TCHAR *sep = (TCHAR *)_tcsrchr(path, '\\'); |
| 409 | TCHAR *sep = (TCHAR *)_tcsrchr(path, INVPATHSEPCH); |
| 405 | 410 | |
| 406 | 411 | // if there's still a separator, and it's not the root, nuke it and recurse |
| 407 | | if (sep != NULL && sep > path && sep[0] != ':' && sep[-1] != '\\') |
| 412 | if (sep != NULL && sep > path && sep[0] != ':' && sep[-1] != INVPATHSEPCH) |
| 408 | 413 | { |
| 409 | 414 | *sep = 0; |
| 410 | 415 | create_path_recursive(path); |
| 411 | | *sep = '\\'; |
| 416 | *sep = INVPATHSEPCH; |
| 412 | 417 | } |
| 413 | 418 | |
| 414 | 419 | // if the path already exists, we're done |