diff options
author | murrayn <github@nesbitt.ca> | 2018-03-07 03:08:55 -0800 |
---|---|---|
committer | murrayn <github@nesbitt.ca> | 2018-03-14 19:07:30 -0700 |
commit | 8674e74b47c1f6e86a367cfbc738fcc9812b616b (patch) | |
tree | acf9d52938e2021e4dcb9ad1c89e02ae8362d82a /src/util.cpp | |
parent | b225010a808d475cbb53aeed484295f8dc8751c4 (diff) |
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 82c99a3c2f..7ea7972564 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) { |