Skip to content
Bitcoin Roots

v29.4-roots.4 · Commit 2: [PATCH 02/37] runtime: preserve shared operator controls

src/util/fs_helpers.h

Before: src/util/fs_helpers.h · After: src/util/fs_helpers.h

File metadata
index 28dd6d979d5253ea5a09c58bd68d670e10ad6f9b..e5ce1a3ce298b6193af6915e4d1754857af7f61a 100644

Download original patch · Release notes

Diff rows 1–38 of 38. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

src/util/fs_helpers.h CHANGED
@@ -55,6 +55,15 @@ bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes = 0);
55
  */
56
  std::streampos GetFileSize(const char* path, std::streamsize max = std::numeric_limits<std::streamsize>::max());
57
 
 
 
 
 
 
 
 
 
 
58
  /** Release all directory locks. This is used for unit testing only, at runtime
59
  * the global destructor will take care of the locks.
60
  */
@@ -76,8 +85,23 @@ std::string PermsToSymbolicString(fs::perms p);
76
  */
77
  std::optional<fs::perms> InterpretPermString(const std::string& s);
78
 
 
 
 
 
 
 
 
 
79
  #ifdef WIN32
80
  fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
81
  #endif
82
 
 
 
 
 
 
 
 
83
  #endif // BITCOIN_UTIL_FS_HELPERS_H
 
55
  */
56
  std::streampos GetFileSize(const char* path, std::streamsize max = std::numeric_limits<std::streamsize>::max());
57
 
58
+ //! Return the original FILE* unchanged. On systems that support it,
59
+ //! also advise the OS that the file will be accessed sequentially.
60
+ FILE* AdviseSequential(FILE*);
61
+
62
+ //! Close a file and return the result of fclose(). On systems that
63
+ //! support it, advise the OS to remove the file contents from the page
64
+ //! cache (which can help on memory-constrained systems).
65
+ int CloseAndUncache(FILE*);
66
+
67
  /** Release all directory locks. This is used for unit testing only, at runtime
68
  * the global destructor will take care of the locks.
69
  */
 
85
  */
86
  std::optional<fs::perms> InterpretPermString(const std::string& s);
87
 
88
+ /** Check if a directory is writable by creating a temporary file on it.
89
+ *
90
+ * @param[in] dir_path Path of the directory to test
91
+ * @return true if a temporary file could be created and removed, false otherwise.
92
+ * @throw std::runtime_error if dir_path is not a directory.
93
+ */
94
+ bool IsDirWritable(const fs::path& dir_path);
95
+
96
  #ifdef WIN32
97
  fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
98
  #endif
99
 
100
+ /** Determine whether the given path is a symbolic link or a reparse point on windows
101
+ *
102
+ * @param[in] path The path to check
103
+ * @return Whether path is a symlink or reparse point
104
+ */
105
+ bool IsSymlink(const fs::path& path);
106
+
107
  #endif // BITCOIN_UTIL_FS_HELPERS_H