Commented out debug statements again
[oweals/minetest.git] / src / filesys.cpp
index 2fd90c237c4e5e44e4a6f08ac9ec281ccd6daa02..8aa10ba585408730bacc72e53e7cae96dd1dad88 100644 (file)
@@ -28,7 +28,7 @@ namespace fs
 #ifdef _WIN32 // WINDOWS
 
 #define _WIN32_WINNT 0x0501
-#include <Windows.h>
+#include <windows.h>
 #include <stdio.h>
 #include <malloc.h>
 #include <tchar.h> 
@@ -157,7 +157,11 @@ bool RecursiveDelete(std::string path)
        
        int r = SHFileOperation(&sfo);
 
-       return (r == 0);
+       if(r != 0)
+               std::cerr<<"SHFileOperation returned "<<r<<std::endl;
+
+       //return (r == 0);
+       return true;
 }
 
 #else // POSIX
@@ -250,7 +254,7 @@ bool RecursiveDelete(std::string path)
                execv(argv[0], argv);
                
                // Execv shouldn't return. Failed.
-               return false;
+               _exit(1);
        }
        else
        {
@@ -286,5 +290,24 @@ bool RecursiveDeleteContent(std::string path)
        return true;
 }
 
+bool CreateAllDirs(std::string path)
+{
+
+       size_t pos;
+       std::vector<std::string> tocreate;
+       std::string basepath = path;
+       while(!PathExists(basepath))
+       {
+               tocreate.push_back(basepath);
+               pos = basepath.rfind('/');
+               if(pos == std::string::npos)
+                       return false;
+               basepath = basepath.substr(0,pos);
+       }
+       for(int i=tocreate.size()-1;i>=0;i--)
+               CreateDir(tocreate[i]);
+       return true;
+}
+
 } // namespace fs