diff options
author | mamehaze <mamehaze@users.noreply.github.com> | 2015-01-09 19:25:12 +0000 |
---|---|---|
committer | mamehaze <mamehaze@users.noreply.github.com> | 2015-01-09 19:25:12 +0000 |
commit | 1e81bd255798f439ebcd219d036c60798dc14feb (patch) | |
tree | b254493d95a0f6f243bc1e226f02302669f14541 | |
parent | 93d461892e422ecd10862953e05b963acf892cdf (diff) |
restore path creation in SDLMAME builds on Windows.
note, this is a bit ugly, I humbly ask that if somebody has a better solution they revert this and apply it instead.
The root of this issue is when SDL builds on Windows were converted over to simply using the WIndows file handling (so that large files requiring 64-bit pointers. eg. laserdisc CHDs would work) sdlfile.c simply includes winfile.c from the Windows code.
The rest of the SDL code is however passing incorrect slashes in the paths to the Windows code, causing it to fail when creating new folders.
To fix this I've simply copied a #if defined that was used in the sdlfile.c code, and applied it to the winfile.c code in places where path seperators are used, thus fixing the issue for both regular and SDL builds on Windows. It might however be more appropriate to filter / correct these further up?
-rw-r--r-- | src/osd/windows/winfile.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/osd/windows/winfile.c b/src/osd/windows/winfile.c index 9aa168f103e..0c43fccdb61 100644 --- a/src/osd/windows/winfile.c +++ b/src/osd/windows/winfile.c @@ -22,6 +22,12 @@ #include "winutil.h" #include "winutf8.h" +#if defined(SDLMAME_WIN32) || defined(SDLMAME_OS2) +#define INVPATHSEPCH '/' +#else +#define INVPATHSEPCH '\\' +#endif + #include "winfile.h" //============================================================ @@ -118,17 +124,16 @@ file_error osd_open(const char *path, UINT32 openflags, osd_file **file, UINT64 if ((*file)->handle == INVALID_HANDLE_VALUE) { DWORD error = GetLastError(); - // create the path if necessary if (error == ERROR_PATH_NOT_FOUND && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS)) { - TCHAR *pathsep = _tcsrchr((*file)->filename, '\\'); + TCHAR *pathsep = _tcsrchr((*file)->filename, INVPATHSEPCH); if (pathsep != NULL) { // create the path up to the file *pathsep = 0; error = create_path_recursive((*file)->filename); - *pathsep = '\\'; + *pathsep = INVPATHSEPCH; // attempt to reopen the file if (error == NO_ERROR) @@ -401,14 +406,14 @@ int osd_uchar_from_osdchar(UINT32 *uchar, const char *osdchar, size_t count) DWORD create_path_recursive(const TCHAR *path) { - TCHAR *sep = (TCHAR *)_tcsrchr(path, '\\'); + TCHAR *sep = (TCHAR *)_tcsrchr(path, INVPATHSEPCH); // if there's still a separator, and it's not the root, nuke it and recurse - if (sep != NULL && sep > path && sep[0] != ':' && sep[-1] != '\\') + if (sep != NULL && sep > path && sep[0] != ':' && sep[-1] != INVPATHSEPCH) { *sep = 0; create_path_recursive(path); - *sep = '\\'; + *sep = INVPATHSEPCH; } // if the path already exists, we're done |