From 2f0a0bce4c663b7df2ed229ef897dcf3fd878ec6 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sun, 11 Apr 2021 11:32:29 -0400 Subject: [PATCH] Revert to my old userdata folder creation code. PhysFS requires a write dir to create a directory, so the first PHYSFS_mkdir never could have worked. Because of that we need to go back to the old mkdir, and since we're bringing that back we can reuse it for saves/levels, because we know it works and we don't have to worry about middlewares ruining anything. --- desktop_version/src/FileSystemUtils.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 741fbf79..c14908cd 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -16,11 +16,14 @@ #if defined(_WIN32) #include #include +#define mkdir(a, b) CreateDirectory(a, NULL) +#define VNEEDS_MIGRATION (mkdirResult != 0) #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) || defined(__DragonFly__) #include #include #include #include +#define VNEEDS_MIGRATION (mkdirResult == 0) #define MAX_PATH PATH_MAX #endif @@ -80,24 +83,21 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath) PLATFORM_getOSDirectory(output); } - /* Create base user directory, mount */ - mkdirResult = PHYSFS_mkdir(output); + /* Create base user directory (NOT with PhysFS!), mount */ + mkdirResult = mkdir(output, 777); /* Mount our base user directory */ PHYSFS_mount(output, NULL, 0); PHYSFS_setWriteDir(output); printf("Base directory: %s\n", output); - /* Create the save/level folders */ - mkdirResult |= PHYSFS_mkdir("saves"); - mkdirResult |= PHYSFS_mkdir("levels"); - /* Store full save directory */ SDL_snprintf(saveDir, sizeof(saveDir), "%s%s%s", output, "saves", pathSep ); + mkdir(saveDir, 0777); /* FIXME: Why did I not | this? -flibit */ printf("Save directory: %s\n", saveDir); /* Store full level directory */ @@ -106,10 +106,11 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath) "levels", pathSep ); + mkdirResult |= mkdir(levelDir, 0777); printf("Level directory: %s\n", levelDir); /* We didn't exist until now, migrate files! */ - if (mkdirResult == 0) + if (VNEEDS_MIGRATION) { PLATFORM_migrateSaveData(output); }