From 8674e74b47c1f6e86a367cfbc738fcc9812b616b Mon Sep 17 00:00:00 2001 From: murrayn Date: Wed, 7 Mar 2018 03:08:55 -0800 Subject: Provide relevant error message if datadir is not writable. --- src/util.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/util.cpp') 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) { -- cgit v1.2.3