MCPcopy Create free account
hub / github.com/ElementsProject/elements / path

Class path

src/fs.h:29–58  ·  view source on GitHub ↗

* Path class wrapper to block calls to the fs::path(std::string) implicit * constructor and the fs::path::string() method, which have unsafe and * unpredictable behavior on Windows (see implementation note in * \ref PathToString for details) */

Source from the content-addressed store, hash-verified

27 * \ref PathToString for details)
28 */
29class path : public std::filesystem::path
30{
31public:
32 using std::filesystem::path::path;
33
34 // Allow path objects arguments for compatibility.
35 path(std::filesystem::path path) : std::filesystem::path::path(std::move(path)) {}
36 path& operator=(std::filesystem::path path) { std::filesystem::path::operator=(std::move(path)); return *this; }
37 path& operator/=(std::filesystem::path path) { std::filesystem::path::operator/=(std::move(path)); return *this; }
38
39 // Allow literal string arguments, which are safe as long as the literals are ASCII.
40 path(const char* c) : std::filesystem::path(c) {}
41 path& operator=(const char* c) { std::filesystem::path::operator=(c); return *this; }
42 path& operator/=(const char* c) { std::filesystem::path::operator/=(c); return *this; }
43 path& append(const char* c) { std::filesystem::path::append(c); return *this; }
44
45 // Disallow std::string arguments to avoid locale-dependent decoding on windows.
46 path(std::string) = delete;
47 path& operator=(std::string) = delete;
48 path& operator/=(std::string) = delete;
49 path& append(std::string) = delete;
50
51 // Disallow std::string conversion method to avoid locale-dependent encoding on windows.
52 std::string string() const = delete;
53
54 // Required for path overloads in <fstream>.
55 // See https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=96e0367ead5d8dcac3bec2865582e76e2fbab190
56 path& make_preferred() { std::filesystem::path::make_preferred(); return *this; }
57 path filename() const { return std::filesystem::path::filename(); }
58};
59
60// Disallow implicit std::string conversion for absolute to avoid
61// locale-dependent encoding on windows.

Callers 10

AbsPathJoinFunction · 0.85
PathFromStringFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
checkMethod · 0.85
GetAutostartDirFunction · 0.85
savemempoolFunction · 0.85
ClearPathCacheMethod · 0.85
GetDefaultDataDirFunction · 0.85
GetSpecialFolderPathFunction · 0.85

Calls

no outgoing calls

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68