mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-04 04:45:10 +02:00
Turn TryCreateDirectory() into TryCreateDirectories()
Use case: TryCreateDirectory(GetDataDir() / "blocks" / "index") would fail if the blocks directory was not explicitly created before. The line that did so was in a weird location and could be removed as a result.
This commit is contained in:
@@ -653,21 +653,21 @@ bool RenameOver(fs::path src, fs::path dest)
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignores exceptions thrown by Boost's create_directory if the requested directory exists.
|
||||
* Ignores exceptions thrown by Boost's create_directories if the requested directory exists.
|
||||
* Specifically handles case where path p exists, but it wasn't possible for the user to
|
||||
* write to the parent directory.
|
||||
*/
|
||||
bool TryCreateDirectory(const fs::path& p)
|
||||
bool TryCreateDirectories(const fs::path& p)
|
||||
{
|
||||
try
|
||||
{
|
||||
return fs::create_directory(p);
|
||||
return fs::create_directories(p);
|
||||
} catch (const fs::filesystem_error&) {
|
||||
if (!fs::exists(p) || !fs::is_directory(p))
|
||||
throw;
|
||||
}
|
||||
|
||||
// create_directory didn't create the directory, it had to have existed already
|
||||
// create_directories didn't create the directory, it had to have existed already
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user