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