]> git.tdb.fi Git - libs/core.git/blob - source/fs/dir.h
Add move semantics to Variant
[libs/core.git] / source / fs / dir.h
1 #ifndef MSP_FS_DIR_H_
2 #define MSP_FS_DIR_H_
3
4 #include <stdexcept>
5 #include <string>
6 #include <vector>
7 #include <msp/core/mspcore_api.h>
8 #include "path.h"
9
10 namespace Msp {
11 namespace FS {
12
13 class MSPCORE_API not_a_directory: public std::runtime_error
14 {
15 public:
16         not_a_directory(const Path &);
17         ~not_a_directory() throw() override = default;
18 };
19
20 /// Creates a directory
21 MSPCORE_API void mkdir(const Path &path, int mode);
22
23 /// Creates a directory and any required parent directories
24 MSPCORE_API void mkpath(const Path &path, int mode);
25
26 /// Removes a directory, which must be empty
27 MSPCORE_API void rmdir(const Path &path);
28
29 /// Removes a directory and anything it contains
30 MSPCORE_API void rmpath(const Path &path);
31
32 /// Lists the contents of a directory
33 MSPCORE_API std::vector<std::string> list_files(const Path &path);
34
35 /// Lists the contents of a directory, filtered with a regex
36 MSPCORE_API std::vector<std::string> list_filtered(const Path &path, const std::string &filter);
37
38 /// Returns the current working directory
39 MSPCORE_API Path getcwd();
40
41 /// Changes the current working directory
42 MSPCORE_API void chdir(const Path &);
43
44 /// Returns the user's home directory
45 MSPCORE_API Path get_home_dir();
46
47 /// Returns a directory suitable for storing user-specific data.
48 MSPCORE_API Path get_user_data_dir();
49
50 /// Returns a directory containing system-wide configuration.
51 MSPCORE_API Path get_sys_conf_dir();
52
53 /// Returns a directory containing immutable system-wide data.
54 MSPCORE_API Path get_sys_data_dir();
55
56 /// Returns a directory containing system-wide architecture-specific files.
57 MSPCORE_API Path get_sys_lib_dir();
58
59 /** Looks for a file in a list of paths.  Returns the absolute path to the
60 first existing location, or an empty Path if the file is not found at all. */
61 MSPCORE_API Path path_lookup(const std::string &, const std::vector<Path> &);
62
63 /** Looks for a file using the PATH environment variable. */
64 MSPCORE_API Path path_lookup(const std::string &);
65
66 } // namespace FS
67 } // namespace Msp
68
69 #endif