Previous 199869 Revisions Next

r34292 Friday 9th January, 2015 at 19:25:12 UTC by David Haywood
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?
[src/osd/windows]winfile.c

trunk/src/osd/windows/winfile.c
r242803r242804
2222#include "winutil.h"
2323#include "winutf8.h"
2424
25#if defined(SDLMAME_WIN32) || defined(SDLMAME_OS2)
26#define INVPATHSEPCH '/'
27#else
28#define INVPATHSEPCH '\\'
29#endif
30
2531#include "winfile.h"
2632
2733//============================================================
r242803r242804
118124   if ((*file)->handle == INVALID_HANDLE_VALUE)
119125   {
120126      DWORD error = GetLastError();
121
122127      // create the path if necessary
123128      if (error == ERROR_PATH_NOT_FOUND && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS))
124129      {
125         TCHAR *pathsep = _tcsrchr((*file)->filename, '\\');
130         TCHAR *pathsep = _tcsrchr((*file)->filename, INVPATHSEPCH);
126131         if (pathsep != NULL)
127132         {
128133            // create the path up to the file
129134            *pathsep = 0;
130135            error = create_path_recursive((*file)->filename);
131            *pathsep = '\\';
136            *pathsep = INVPATHSEPCH;
132137
133138            // attempt to reopen the file
134139            if (error == NO_ERROR)
r242803r242804
401406
402407DWORD create_path_recursive(const TCHAR *path)
403408{
404   TCHAR *sep = (TCHAR *)_tcsrchr(path, '\\');
409   TCHAR *sep = (TCHAR *)_tcsrchr(path, INVPATHSEPCH);
405410
406411   // 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)
408413   {
409414      *sep = 0;
410415      create_path_recursive(path);
411      *sep = '\\';
416      *sep = INVPATHSEPCH;
412417   }
413418
414419   // if the path already exists, we're done


Previous 199869 Revisions Next


© 1997-2024 The MAME Team