Commits

Bart van Strien committed 859691e

Hopefully fix appdata dir creation on windows

Comments (0)

Files changed (1)

src/modules/filesystem/physfs/Filesystem.cpp

 
 namespace
 {
-	std::string getDriveRoot(const std::string &input)
+	size_t getDriveDelim(const std::string &input)
 	{
 		for (size_t i = 0; i < input.size(); ++i)
 			if (input[i] == '/' || input[i] == '\\')
-				return input.substr(0, i+1);
+				return i;
 		// Something's horribly wrong
-		return "";
+		return 0;
+	}
+
+	std::string getDriveRoot(const std::string &input)
+	{
+		return input.substr(0, getDriveDelim(input)+1);
+	}
+
+	std::string skipDriveRoot(const std::string &input)
+	{
+		return input.substr(getDriveDelim(input)+1);
 	}
 }
 
 
 	// Set the appdata folder as writable directory.
 	// (We must create the save folder before mounting it).
-	if (!PHYSFS_setWriteDir(getDriveRoot(getAppdataDirectory()).c_str()))
+	if (!PHYSFS_setWriteDir(getDriveRoot(save_path_full).c_str()))
 		return false;
 
 	// Create the save folder. (We're now "at" %APPDATA%).
-	bool success = false;
-	if (fused)
-		success = mkdir(save_path_full.c_str());
-	else
-		success = mkdir(save_path_full.c_str());
-
-	if (!success)
+	if (!mkdir(skipDriveRoot(save_path_full).c_str()))
 	{
 		// Clear the write directory in case of error.
 		PHYSFS_setWriteDir(0);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.