mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge #12630: Provide useful error message if datadir is not writable.
8674e74 Provide relevant error message if datadir is not writable. (murrayn)
Pull request description:
If the --datadir exists, but is not writable, the current error message on startup is 'Cannot obtain a lock on data directory foo. Bitcoin Core is probably already running.' This is misleading.
I believe this PR addresses #11668, although the issue is not Windows-specific.
Tree-SHA512: 10cbbaea433072aee4fb3e8938a72073c7a5c841f7a7685c9e12549c322b2925c7d34bac254ac33021b23132bfc352c058712bc9542298cf86f8fd9757f528b2
This commit is contained in:
commit
c290508a5e
4 changed files with 33 additions and 0 deletions
13
src/util.cpp
13
src/util.cpp
|
|
@ -419,6 +419,19 @@ void ReleaseDirectoryLocks()
|
|||
dir_locks.clear();
|
||||
}
|
||||
|
||||
bool DirIsWritable(const fs::path& directory)
|
||||
{
|
||||
fs::path tmpFile = directory / fs::unique_path();
|
||||
|
||||
FILE* file = fsbridge::fopen(tmpFile, "a");
|
||||
if (!file) return false;
|
||||
|
||||
fclose(file);
|
||||
remove(tmpFile);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Interpret string as boolean, for argument parsing */
|
||||
static bool InterpretBool(const std::string& strValue)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue