7 #include <msp/core/mspcore_api.h>
13 class MSPCORE_API not_a_directory: public std::runtime_error
16 not_a_directory(const Path &);
17 ~not_a_directory() throw() override = default;
20 /// Creates a directory
21 MSPCORE_API void mkdir(const Path &path, int mode);
23 /// Creates a directory and any required parent directories
24 MSPCORE_API void mkpath(const Path &path, int mode);
26 /// Removes a directory, which must be empty
27 MSPCORE_API void rmdir(const Path &path);
29 /// Removes a directory and anything it contains
30 MSPCORE_API void rmpath(const Path &path);
32 /// Lists the contents of a directory
33 MSPCORE_API std::vector<std::string> list_files(const Path &path);
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);
38 /// Returns the current working directory
39 MSPCORE_API Path getcwd();
41 /// Changes the current working directory
42 MSPCORE_API void chdir(const Path &);
44 /// Returns the user's home directory
45 MSPCORE_API Path get_home_dir();
47 /// Returns a directory suitable for storing user-specific data.
48 MSPCORE_API Path get_user_data_dir();
50 /// Returns a directory containing system-wide configuration.
51 MSPCORE_API Path get_sys_conf_dir();
53 /// Returns a directory containing immutable system-wide data.
54 MSPCORE_API Path get_sys_data_dir();
56 /// Returns a directory containing system-wide architecture-specific files.
57 MSPCORE_API Path get_sys_lib_dir();
59 /// Returns a directory suitable for storing temporary files.
60 MSPCORE_API Path get_temp_dir();
62 /** Looks for a file in a list of paths. Returns the absolute path to the
63 first existing location, or an empty Path if the file is not found at all. */
64 MSPCORE_API Path path_lookup(const std::string &, const std::vector<Path> &);
66 /** Looks for a file using the PATH environment variable. */
67 MSPCORE_API Path path_lookup(const std::string &);