X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ffilesys.cpp;h=5ffb4506ea3c8bb50dc774b3e9db1e930f1748ae;hb=5a02c376ea5f2e7f1dd0a2bd4f08bf953ed4bfc8;hp=be61ba430465d987150d1a6b3294dc9fccae4bb7;hpb=78bd902b9f770dee9b4d41f03c289574e6b59151;p=dragonfireclient.git diff --git a/src/filesys.cpp b/src/filesys.cpp index be61ba430..5ffb4506e 100644 --- a/src/filesys.cpp +++ b/src/filesys.cpp @@ -27,9 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #include "config.h" #include "porting.h" -#ifdef __ANDROID__ -#include "settings.h" // For g_settings -#endif namespace fs { @@ -295,27 +292,26 @@ bool RecursiveDelete(const std::string &path) infostream<<"Removing \""<(argv)); // Execv shouldn't return. Failed. _exit(1); @@ -327,7 +323,6 @@ bool RecursiveDelete(const std::string &path) pid_t tpid; do{ tpid = wait(&child_status); - //if(tpid != child_pid) process_terminated(tpid); }while(tpid != child_pid); return (child_status == 0); } @@ -361,8 +356,9 @@ std::string TempPath() compatible with lua's os.tmpname which under the default configuration hardcodes mkstemp("/tmp/lua_XXXXXX"). */ + #ifdef __ANDROID__ - return g_settings->get("TMPFolder"); + return porting::path_cache; #else return DIR_DELIM "tmp"; #endif @@ -403,21 +399,6 @@ void GetRecursiveSubPaths(const std::string &path, } } -bool DeletePaths(const std::vector &paths) -{ - bool success = true; - // Go backwards to succesfully delete the output of GetRecursiveSubPaths - for(int i=paths.size()-1; i>=0; i--){ - const std::string &path = paths[i]; - bool did = DeleteSingleFileOrEmptyDirectory(path); - if(!did){ - errorstream<<"Failed to delete "< filename) + filename = tmp; + } return filename ? filename + 1 : path; } @@ -740,6 +727,21 @@ bool safeWriteToFile(const std::string &path, const std::string &content) return true; } +bool ReadFile(const std::string &path, std::string &out) +{ + std::ifstream is(path, std::ios::binary | std::ios::ate); + if (!is.good()) { + return false; + } + + auto size = is.tellg(); + out.resize(size); + is.seekg(0); + is.read(&out[0], size); + + return true; +} + bool Rename(const std::string &from, const std::string &to) { return rename(from.c_str(), to.c_str()) == 0;