Skip to content

Commit 228c319

Browse files
committed
Merge #9895: Turn TryCreateDirectory() into TryCreateDirectories()
1d1ea9f Turn TryCreateDirectory() into TryCreateDirectories() (Marko Bencun) Tree-SHA512: 49a524167bcf66e351a964c88d09cb3bcee12769a32da83410e3ba649fa4bcdbf0478d41e4d09bb55adb9b3f122e742271db6feb30bbafe2a7973542b5f10f79
2 parents c94b89e + 1d1ea9f commit 228c319

File tree

6 files changed

+8
-10
lines changed

6 files changed

+8
-10
lines changed

src/dbwrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ CDBWrapper::CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory, bo
108108
leveldb::Status result = leveldb::DestroyDB(path.string(), options);
109109
dbwrapper_private::HandleError(result);
110110
}
111-
TryCreateDirectory(path);
111+
TryCreateDirectories(path);
112112
LogPrintf("Opening LevelDB in %s\n", path.string());
113113
}
114114
leveldb::Status status = leveldb::DB::Open(options, path.string(), &pdb);

src/init.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,8 +1408,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
14081408
fReindex = GetBoolArg("-reindex", false);
14091409
bool fReindexChainState = GetBoolArg("-reindex-chainstate", false);
14101410

1411-
fs::create_directories(GetDataDir() / "blocks");
1412-
14131411
// cache size calculations
14141412
int64_t nTotalCache = (GetArg("-dbcache", nDefaultDbCache) << 20);
14151413
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache

src/qt/intro.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ bool Intro::pickDataDirectory()
214214
}
215215
dataDir = intro.getDataDirectory();
216216
try {
217-
TryCreateDirectory(GUIUtil::qstringToBoostPath(dataDir));
217+
TryCreateDirectories(GUIUtil::qstringToBoostPath(dataDir));
218218
break;
219219
} catch (const fs::filesystem_error&) {
220220
QMessageBox::critical(0, tr(PACKAGE_NAME),

src/util.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,21 +651,21 @@ bool RenameOver(fs::path src, fs::path dest)
651651
}
652652

653653
/**
654-
* Ignores exceptions thrown by Boost's create_directory if the requested directory exists.
654+
* Ignores exceptions thrown by Boost's create_directories if the requested directory exists.
655655
* Specifically handles case where path p exists, but it wasn't possible for the user to
656656
* write to the parent directory.
657657
*/
658-
bool TryCreateDirectory(const fs::path& p)
658+
bool TryCreateDirectories(const fs::path& p)
659659
{
660660
try
661661
{
662-
return fs::create_directory(p);
662+
return fs::create_directories(p);
663663
} catch (const fs::filesystem_error&) {
664664
if (!fs::exists(p) || !fs::is_directory(p))
665665
throw;
666666
}
667667

668-
// create_directory didn't create the directory, it had to have existed already
668+
// create_directories didn't create the directory, it had to have existed already
669669
return false;
670670
}
671671

src/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ bool TruncateFile(FILE *file, unsigned int length);
152152
int RaiseFileDescriptorLimit(int nMinFD);
153153
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
154154
bool RenameOver(fs::path src, fs::path dest);
155-
bool TryCreateDirectory(const fs::path& p);
155+
bool TryCreateDirectories(const fs::path& p);
156156
fs::path GetDefaultDataDir();
157157
const fs::path &GetDataDir(bool fNetSpecific = true);
158158
void ClearDatadirCache();

src/wallet/db.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool CDBEnv::Open(const fs::path& pathIn)
7474

7575
strPath = pathIn.string();
7676
fs::path pathLogDir = pathIn / "database";
77-
TryCreateDirectory(pathLogDir);
77+
TryCreateDirectories(pathLogDir);
7878
fs::path pathErrorFile = pathIn / "db.log";
7979
LogPrintf("CDBEnv::Open: LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string());
8080

0 commit comments

Comments
 (0)