From 0e6786988ed4d92e4a1961b3231e1de5cfec3cb7 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Fri, 4 Oct 2013 14:30:56 +0200 Subject: [PATCH] Try to create appdata dir if it doesn't exist (hopefully resolves #680) --- src/modules/filesystem/physfs/Filesystem.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/modules/filesystem/physfs/Filesystem.cpp b/src/modules/filesystem/physfs/Filesystem.cpp index 2f56bb526..2db6fb023 100644 --- a/src/modules/filesystem/physfs/Filesystem.cpp +++ b/src/modules/filesystem/physfs/Filesystem.cpp @@ -27,6 +27,18 @@ #include "Filesystem.h" +namespace +{ + std::string getDriveRoot(const std::string &input) + { + for (int i = 0; i < input.size(); ++i) + if (input[i] == '/' || input[i] == '\\') + return input.substr(0, i+1); + // Something's horribly wrong + return ""; + } +} + namespace love { namespace filesystem @@ -153,15 +165,15 @@ bool Filesystem::setupWriteDirectory() // Set the appdata folder as writable directory. // (We must create the save folder before mounting it). - if (!PHYSFS_setWriteDir(getAppdataDirectory())) + if (!PHYSFS_setWriteDir(getDriveRoot(getAppdataDirectory()).c_str())) return false; // Create the save folder. (We're now "at" %APPDATA%). bool success = false; if (fused) - success = mkdir(save_identity.c_str()); + success = mkdir(save_path_full.c_str()); else - success = mkdir(save_path_relative.c_str()); + success = mkdir(save_path_full.c_str()); if (!success) {