mirror of
https://github.com/holub/mame
synced 2025-07-06 02:18:09 +03:00
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?
This commit is contained in:
parent
93d461892e
commit
1e81bd2557
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user