]> git.tdb.fi Git - libs/core.git/blob - source/fs/utils.h
Add move semantics to Variant
[libs/core.git] / source / fs / utils.h
1 #ifndef MSP_FS_UTILS_H_
2 #define MSP_FS_UTILS_H_
3
4 #include <msp/core/mspcore_api.h>
5 #include "path.h"
6
7 namespace Msp {
8 namespace FS {
9
10 /// Extracts the last component of the path.
11 MSPCORE_API std::string basename(const Path &);
12
13 /// Removes the last component from the path.
14 MSPCORE_API Path dirname(const Path &);
15
16 /** Returns the base part of a filename.  This includes everything up to the
17 last dot, but not the dot itself. */
18 MSPCORE_API std::string basepart(const std::string &);
19
20 /** Returns the extension part of a filename.  This includes the last dot and
21 everything after it. */
22 MSPCORE_API std::string extpart(const std::string &);
23
24 /// Fixes the case of a path to match files / directories on the filesystem.
25 MSPCORE_API Path fix_case(const Path &path);
26
27 /// Reads the contents of a symbolic link
28 MSPCORE_API Path readlink(const Path &path);
29
30 /// Resolves all symlinks from a path.  Will always return an absolute path.
31 MSPCORE_API Path realpath(const Path &path);
32
33 /// Removes a file
34 MSPCORE_API void unlink(const Path &path);
35
36 /// Renames a file.  Existing file, if any, is overwritten.
37 MSPCORE_API void rename(const Path &from, const Path &to);
38
39 /** Makes a path relative to some base path.  That is, base/result==path.  Both
40 paths must be either absolute or relative. */
41 MSPCORE_API Path relative(const Path &path, const Path &base);
42
43 /// Returns the longest prefix shared by both paths.
44 MSPCORE_API Path common_ancestor(const Path &, const Path &);
45
46 /** Determines how many levels a path is below another.  Returns -1 if path is
47 not a descendant of parent.  Both paths must be either absolute or relative. */
48 MSPCORE_API int descendant_depth(const Path &path, const Path &parent);
49
50 } // namespace FS
51 } // namespace Msp
52
53 #endif