diff options
| author | murrayn <[email protected]> | 2018-03-07 03:08:55 -0800 |
|---|---|---|
| committer | murrayn <[email protected]> | 2018-03-14 19:07:30 -0700 |
| commit | 8674e74b47c1f6e86a367cfbc738fcc9812b616b (patch) | |
| tree | acf9d52938e2021e4dcb9ad1c89e02ae8362d82a /src/util.cpp | |
| parent | Merge #11372: Address encoding cleanup (diff) | |
| download | discoin-8674e74b47c1f6e86a367cfbc738fcc9812b616b.tar.xz discoin-8674e74b47c1f6e86a367cfbc738fcc9812b616b.zip | |
Provide relevant error message if datadir is not writable.
Diffstat (limited to 'src/util.cpp')
| -rw-r--r-- | src/util.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp index 82c99a3c2..7ea797256 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -418,6 +418,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) { |