]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/filesys.cpp
Update minetest.conf.example and src/settings_translation_file.cpp
[dragonfireclient.git] / src / filesys.cpp
index 4a4a2e4186b55f847edcbd3dda12dd89227a4852..4cefdb807e2580c18a0d559ba0b405414050f34e 100644 (file)
@@ -142,7 +142,7 @@ bool RecursiveDelete(const std::string &path)
                infostream<<"RecursiveDelete: Deleting content of directory "
                                <<path<<std::endl;
                std::vector<DirListNode> content = GetDirListing(path);
-               for(int i=0; i<content.size(); i++){
+               for(size_t i=0; i<content.size(); i++){
                        const DirListNode &n = content[i];
                        std::string fullpath = path + DIR_DELIM + n.name;
                        bool did = RecursiveDelete(fullpath);
@@ -183,7 +183,7 @@ bool DeleteSingleFileOrEmptyDirectory(const std::string &path)
 
 std::string TempPath()
 {
-       DWORD bufsize = GetTempPath(0, "");
+       DWORD bufsize = GetTempPath(0, NULL);
        if(bufsize == 0){
                errorstream<<"GetTempPath failed, error = "<<GetLastError()<<std::endl;
                return "";
@@ -662,6 +662,19 @@ std::string RemoveRelativePathComponents(std::string path)
        return path.substr(0, pos);
 }
 
+std::string AbsolutePath(const std::string &path)
+{
+#ifdef _WIN32
+       char *abs_path = _fullpath(NULL, path.c_str(), MAX_PATH);
+#else
+       char *abs_path = realpath(path.c_str(), NULL);
+#endif
+       if (!abs_path) return "";
+       std::string abs_path_str(abs_path);
+       free(abs_path);
+       return abs_path_str;
+}
+
 const char *GetFilenameFromPath(const char *path)
 {
        const char *filename = strrchr(path, DIR_DELIM_CHAR);