1 #ifndef MSP_FS_UTILS_H_
2 #define MSP_FS_UTILS_H_
9 /// Extracts the last component of the path.
10 std::string basename(const Path &);
12 /// Removes the last component from the path.
13 Path dirname(const Path &);
16 Returns the base part of a filename. This includes everything up to the last
17 dot, but not the dot itself.
19 std::string basepart(const std::string &);
22 Returns the extension part of a filename. This includes the last dot and
25 std::string extpart(const std::string &);
28 Fixes the case of the given path to match files / directories on the
31 Path fix_case(const Path &path);
33 /// Reads the contents of a symbolic link
34 Path readlink(const Path &path);
36 /// Resolves all symlinks from a path. Will always return an absolute path.
37 Path realpath(const Path &path);
40 void unlink(const Path &path);
42 /// Renames a file. Existing file, if any, is overwritten.
43 void rename(const Path &from, const Path &to);
45 /// Makes a path relative to some base path. That is, base/result==path.
46 Path relative(const Path &path, const Path &base);
48 /** Determines how many levels a path is below another. Returns -1 if path is
49 not a descendant of parent. */
50 int descendant_depth(const Path &path, const Path &parent);