Previous 199869 Revisions Next

r34294 Friday 9th January, 2015 at 22:04:59 UTC by David Haywood
actually this is less invasive, based on code that was already there, and works in all cases, previous attempt failed when writing sfiii3 nvram (nw)
[src/osd/windows]winfile.c

trunk/src/osd/windows/winfile.c
r242805r242806
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
3125#include "winfile.h"
3226
3327//============================================================
r242805r242806
9690
9791   // convert the path into something Windows compatible
9892   dst = (*file)->filename;
93#if defined(SDLMAME_WIN32) || defined(SDLMAME_OS2)
9994   for (src = t_path; *src != 0; src++)
95      *dst++ = (*src == '/') ? '\\' : *src;
96#else
97   for (src = t_path; *src != 0; src++)
10098      *dst++ = *src;//(*src == '/') ? '\\' : *src;
99#endif
101100   *dst++ = 0;
102101
103102   // select the file open modes
r242805r242806
127126      // create the path if necessary
128127      if (error == ERROR_PATH_NOT_FOUND && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS))
129128      {
130         TCHAR *pathsep = _tcsrchr((*file)->filename, INVPATHSEPCH);
129         TCHAR *pathsep = _tcsrchr((*file)->filename, '\\');
131130         if (pathsep != NULL)
132131         {
133132            // create the path up to the file
134133            *pathsep = 0;
135134            error = create_path_recursive((*file)->filename);
136            *pathsep = INVPATHSEPCH;
135            *pathsep = '\\';
137136
138137            // attempt to reopen the file
139138            if (error == NO_ERROR)
r242805r242806
406405
407406DWORD create_path_recursive(const TCHAR *path)
408407{
409   TCHAR *sep = (TCHAR *)_tcsrchr(path, INVPATHSEPCH);
408   TCHAR *sep = (TCHAR *)_tcsrchr(path, '\\');
410409
411410   // 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] != '\\')
413412   {
414413      *sep = 0;
415414      create_path_recursive(path);
416      *sep = INVPATHSEPCH;
415      *sep = '\\';
417416   }
418417
419418   // if the path already exists, we're done


Previous 199869 Revisions Next


© 1997-2024 The MAME Team