diff options
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 69ceefc8cd..494d5c4eaf 100644 --- a/src/util.cpp +++ b/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) { |