Skip to content

Commit 15c0da4

Browse files
committed
[Refactor] Complete boost::filesystem namespace in util
1 parent 81ddbf4 commit 15c0da4

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/util.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void PrintExceptionContinue(const std::exception* pex, const char* pszThread)
287287
strMiscWarning = message;
288288
}
289289

290-
boost::filesystem::path GetDefaultDataDir()
290+
fs::path GetDefaultDataDir()
291291
{
292292
// Windows < Vista: C:\Documents and Settings\Username\Application Data\PIVX
293293
// Windows >= Vista: C:\Users\Username\AppData\Roaming\PIVX
@@ -349,30 +349,30 @@ const fs::path& GetDataDir(bool fNetSpecific)
349349

350350
void ClearDatadirCache()
351351
{
352-
pathCached = boost::filesystem::path();
353-
pathCachedNetSpecific = boost::filesystem::path();
352+
pathCached = fs::path();
353+
pathCachedNetSpecific = fs::path();
354354
}
355355

356-
boost::filesystem::path GetConfigFile()
356+
fs::path GetConfigFile()
357357
{
358-
boost::filesystem::path pathConfigFile(GetArg("-conf", "pivx.conf"));
358+
fs::path pathConfigFile(GetArg("-conf", "pivx.conf"));
359359
if (!pathConfigFile.is_complete())
360360
pathConfigFile = GetDataDir(false) / pathConfigFile;
361361

362362
return pathConfigFile;
363363
}
364364

365-
boost::filesystem::path GetMasternodeConfigFile()
365+
fs::path GetMasternodeConfigFile()
366366
{
367-
boost::filesystem::path pathConfigFile(GetArg("-mnconf", "masternode.conf"));
367+
fs::path pathConfigFile(GetArg("-mnconf", "masternode.conf"));
368368
if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir() / pathConfigFile;
369369
return pathConfigFile;
370370
}
371371

372372
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet,
373373
std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet)
374374
{
375-
boost::filesystem::ifstream streamConfig(GetConfigFile());
375+
fs::ifstream streamConfig(GetConfigFile());
376376
if (!streamConfig.good()) {
377377
// Create empty pivx.conf if it does not exist
378378
FILE* configFile = fopen(GetConfigFile().string().c_str(), "a");
@@ -398,14 +398,14 @@ void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet,
398398
}
399399

400400
#ifndef WIN32
401-
boost::filesystem::path GetPidFile()
401+
fs::path GetPidFile()
402402
{
403-
boost::filesystem::path pathPidFile(GetArg("-pid", "pivxd.pid"));
403+
fs::path pathPidFile(GetArg("-pid", "pivxd.pid"));
404404
if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile;
405405
return pathPidFile;
406406
}
407407

408-
void CreatePidFile(const boost::filesystem::path& path, pid_t pid)
408+
void CreatePidFile(const fs::path& path, pid_t pid)
409409
{
410410
FILE* file = fopen(path.string().c_str(), "w");
411411
if (file) {
@@ -415,7 +415,7 @@ void CreatePidFile(const boost::filesystem::path& path, pid_t pid)
415415
}
416416
#endif
417417

418-
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
418+
bool RenameOver(fs::path src, fs::path dest)
419419
{
420420
#ifdef WIN32
421421
return MoveFileExA(src.string().c_str(), dest.string().c_str(),
@@ -431,12 +431,12 @@ bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
431431
* Specifically handles case where path p exists, but it wasn't possible for the user to
432432
* write to the parent directory.
433433
*/
434-
bool TryCreateDirectory(const boost::filesystem::path& p)
434+
bool TryCreateDirectory(const fs::path& p)
435435
{
436436
try {
437-
return boost::filesystem::create_directory(p);
438-
} catch (const boost::filesystem::filesystem_error&) {
439-
if (!boost::filesystem::exists(p) || !boost::filesystem::is_directory(p))
437+
return fs::create_directory(p);
438+
} catch (const fs::filesystem_error&) {
439+
if (!fs::exists(p) || !fs::is_directory(p))
440440
throw;
441441
}
442442

@@ -542,7 +542,7 @@ void AllocateFileRange(FILE* file, unsigned int offset, unsigned int length)
542542
}
543543

544544
#ifdef WIN32
545-
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate)
545+
fs::path GetSpecialFolderPath(int nFolder, bool fCreate)
546546
{
547547
char pszPath[MAX_PATH] = "";
548548

@@ -555,24 +555,24 @@ boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate)
555555
}
556556
#endif
557557

558-
boost::filesystem::path GetTempPath()
558+
fs::path GetTempPath()
559559
{
560560
#if BOOST_FILESYSTEM_VERSION == 3
561-
return boost::filesystem::temp_directory_path();
561+
return fs::temp_directory_path();
562562
#else
563563
// TODO: remove when we don't support filesystem v2 anymore
564-
boost::filesystem::path path;
564+
fs::path path;
565565
#ifdef WIN32
566566
char pszPath[MAX_PATH] = "";
567567

568568
if (GetTempPathA(MAX_PATH, pszPath))
569-
path = boost::filesystem::path(pszPath);
569+
path = fs::path(pszPath);
570570
#else
571-
path = boost::filesystem::path("/tmp");
571+
path = fs::path("/tmp");
572572
#endif
573-
if (path.empty() || !boost::filesystem::is_directory(path)) {
573+
if (path.empty() || !fs::is_directory(path)) {
574574
LogPrintf("GetTempPath(): failed to find temp path\n");
575-
return boost::filesystem::path("");
575+
return fs::path("");
576576
}
577577
return path;
578578
#endif
@@ -620,8 +620,8 @@ void SetupEnvironment()
620620
// in multithreading environments, it is set explicitly by the main thread.
621621
// A dummy locale is used to extract the internal default locale, used by
622622
// boost::filesystem::path, which is then used to explicitly imbue the path.
623-
std::locale loc = boost::filesystem::path::imbue(std::locale::classic());
624-
boost::filesystem::path::imbue(loc);
623+
std::locale loc = fs::path::imbue(std::locale::classic());
624+
fs::path::imbue(loc);
625625
}
626626

627627
bool SetupNetworking()

0 commit comments

Comments
 (0)