commit cd724e02
Replaced the platform dependent create dir with mkdir in PhysFS. This means less platform dependend code.
Changed files
| M | source/code/main.cpp before |
| M | source/code/os.cpp before |
| M | source/code/os.hpp before |
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 8e3789e..99bb240 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -110,6 +110,14 @@ static void PhysFsSetSearchPath(const vector<string>& paths, const string& savep
}
+static void PhysFsCreateFolders() {
+ //We first create the folder there we will save (only on UNIX systems)
+ //we call the external command "mkdir"... the user might have renamed this, but we hope he hasn't
+ PHYSFS_mkdir("screenshots");
+ PHYSFS_mkdir("replays");
+ PHYSFS_mkdir("puzzles");
+}
+
//Load all image files to memory
static int InitImages(sago::SagoSpriteHolder& holder) {
bricks[0] = holder.GetSprite("blue");
@@ -1703,7 +1711,7 @@ int main(int argc, char* argv[]) {
return 0;
}
//Os create folders must be after the paramters because they can change the home folder
- OsCreateFolders();
+ PhysFsCreateFolders();
SoundEnabled = true;
MusicEnabled = true;
diff --git a/source/code/os.cpp b/source/code/os.cpp
index abe08a1..bd4de29 100644
--- a/source/code/os.cpp
+++ b/source/code/os.cpp
@@ -23,6 +23,7 @@ http://blockattack.net
#include "os.hpp"
#include <iostream>
+#include <physfs.h>
#ifdef __unix__
#include <pwd.h>
@@ -126,27 +127,3 @@ std::string getPuzzleSetSavePath() {
#endif
return ret;
}
-
-static void OsCreateFolderInSaveGames(const string& path) {
- string cmd = "mkdir -p "+getPathToSaveFiles()+"/"+path;
-#if defined(__unix__)
- int retcode = system(cmd.c_str());
- if (retcode != 0) {
- cerr << "Failed to create: " << getPathToSaveFiles()+"/"+path << endl;
- }
-#elif defined(_WIN32)
- //Now for Windows NT/2k/xp/2k3 etc.
- string tempA = getMyDocumentsPath()+"\\My Games";
- CreateDirectory(tempA.c_str(),nullptr);
- tempA += "/"+path;
- CreateDirectory(tempA.c_str(),nullptr);
-#endif
-}
-
-void OsCreateFolders() {
- //We first create the folder there we will save (only on UNIX systems)
- //we call the external command "mkdir"... the user might have renamed this, but we hope he hasn't
- OsCreateFolderInSaveGames("screenshots");
- OsCreateFolderInSaveGames("replays");
- OsCreateFolderInSaveGames("puzzles");
-}
\ No newline at end of file
diff --git a/source/code/os.hpp b/source/code/os.hpp
index e2cd929..7f6c478 100644
--- a/source/code/os.hpp
+++ b/source/code/os.hpp
@@ -34,6 +34,4 @@ std::string getMyDocumentsPath();
void setPathToSaveFiles(const std::string& path);
-std::string getPuzzleSetSavePath();
-
-void OsCreateFolders();
\ No newline at end of file
+std::string getPuzzleSetSavePath();
\ No newline at end of file