diff --git a/src/util.cpp b/src/util.cpp index 4a81cd1844b4a..c09111badb12a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -287,7 +287,7 @@ void PrintExceptionContinue(const std::exception* pex, const char* pszThread) strMiscWarning = message; } -boost::filesystem::path GetDefaultDataDir() +fs::path GetDefaultDataDir() { // Windows < Vista: C:\Documents and Settings\Username\Application Data\PIVX // Windows >= Vista: C:\Users\Username\AppData\Roaming\PIVX @@ -349,22 +349,22 @@ const fs::path& GetDataDir(bool fNetSpecific) void ClearDatadirCache() { - pathCached = boost::filesystem::path(); - pathCachedNetSpecific = boost::filesystem::path(); + pathCached = fs::path(); + pathCachedNetSpecific = fs::path(); } -boost::filesystem::path GetConfigFile() +fs::path GetConfigFile() { - boost::filesystem::path pathConfigFile(GetArg("-conf", "pivx.conf")); + fs::path pathConfigFile(GetArg("-conf", "pivx.conf")); if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir(false) / pathConfigFile; return pathConfigFile; } -boost::filesystem::path GetMasternodeConfigFile() +fs::path GetMasternodeConfigFile() { - boost::filesystem::path pathConfigFile(GetArg("-mnconf", "masternode.conf")); + fs::path pathConfigFile(GetArg("-mnconf", "masternode.conf")); if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir() / pathConfigFile; return pathConfigFile; } @@ -372,7 +372,7 @@ boost::filesystem::path GetMasternodeConfigFile() void ReadConfigFile(std::map& mapSettingsRet, std::map >& mapMultiSettingsRet) { - boost::filesystem::ifstream streamConfig(GetConfigFile()); + fs::ifstream streamConfig(GetConfigFile()); if (!streamConfig.good()) { // Create empty pivx.conf if it does not exist FILE* configFile = fopen(GetConfigFile().string().c_str(), "a"); @@ -398,14 +398,14 @@ void ReadConfigFile(std::map& mapSettingsRet, } #ifndef WIN32 -boost::filesystem::path GetPidFile() +fs::path GetPidFile() { - boost::filesystem::path pathPidFile(GetArg("-pid", "pivxd.pid")); + fs::path pathPidFile(GetArg("-pid", "pivxd.pid")); if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile; return pathPidFile; } -void CreatePidFile(const boost::filesystem::path& path, pid_t pid) +void CreatePidFile(const fs::path& path, pid_t pid) { FILE* file = fopen(path.string().c_str(), "w"); if (file) { @@ -415,7 +415,7 @@ void CreatePidFile(const boost::filesystem::path& path, pid_t pid) } #endif -bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest) +bool RenameOver(fs::path src, fs::path dest) { #ifdef WIN32 return MoveFileExA(src.string().c_str(), dest.string().c_str(), @@ -431,12 +431,12 @@ bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest) * Specifically handles case where path p exists, but it wasn't possible for the user to * write to the parent directory. */ -bool TryCreateDirectory(const boost::filesystem::path& p) +bool TryCreateDirectory(const fs::path& p) { try { - return boost::filesystem::create_directory(p); - } catch (const boost::filesystem::filesystem_error&) { - if (!boost::filesystem::exists(p) || !boost::filesystem::is_directory(p)) + return fs::create_directory(p); + } catch (const fs::filesystem_error&) { + if (!fs::exists(p) || !fs::is_directory(p)) throw; } @@ -542,7 +542,7 @@ void AllocateFileRange(FILE* file, unsigned int offset, unsigned int length) } #ifdef WIN32 -boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate) +fs::path GetSpecialFolderPath(int nFolder, bool fCreate) { char pszPath[MAX_PATH] = ""; @@ -555,24 +555,24 @@ boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate) } #endif -boost::filesystem::path GetTempPath() +fs::path GetTempPath() { #if BOOST_FILESYSTEM_VERSION == 3 - return boost::filesystem::temp_directory_path(); + return fs::temp_directory_path(); #else // TODO: remove when we don't support filesystem v2 anymore - boost::filesystem::path path; + fs::path path; #ifdef WIN32 char pszPath[MAX_PATH] = ""; if (GetTempPathA(MAX_PATH, pszPath)) - path = boost::filesystem::path(pszPath); + path = fs::path(pszPath); #else - path = boost::filesystem::path("/tmp"); + path = fs::path("/tmp"); #endif - if (path.empty() || !boost::filesystem::is_directory(path)) { + if (path.empty() || !fs::is_directory(path)) { LogPrintf("GetTempPath(): failed to find temp path\n"); - return boost::filesystem::path(""); + return fs::path(""); } return path; #endif @@ -620,8 +620,8 @@ void SetupEnvironment() // in multithreading environments, it is set explicitly by the main thread. // A dummy locale is used to extract the internal default locale, used by // boost::filesystem::path, which is then used to explicitly imbue the path. - std::locale loc = boost::filesystem::path::imbue(std::locale::classic()); - boost::filesystem::path::imbue(loc); + std::locale loc = fs::path::imbue(std::locale::classic()); + fs::path::imbue(loc); } bool SetupNetworking()