]> git.tdb.fi Git - libs/core.git/blob - source/fs/dir.h
Exception rework for fs components
[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 <string>
6 #include "path.h"
7
8 namespace Msp {
9 namespace FS {
10
11 class not_a_directory: public std::runtime_error
12 {
13 public:
14         not_a_directory(const Path &);
15         virtual ~not_a_directory() throw() { }
16 };
17
18 /// Creates a directory
19 void mkdir(const Path &path, int mode);
20
21 /// Creates a directory and any required parent directories
22 void mkpath(const Path &path, int mode);
23
24 /// Removes a directory, which must be empty
25 void rmdir(const Path &path);
26
27 /// Removes a directory and anything it contains
28 void rmpath(const Path &path);
29
30 /// Lists the contents of a directory
31 std::list<std::string> list_files(const Path &path);
32
33 /// Lists the contents of a directory, filtered with a regex
34 std::list<std::string> list_filtered(const Path &path, const std::string &filter);
35
36 /// Returns the current working directory
37 Path getcwd();
38
39 /// Returns the user's home directory
40 Path get_home_dir();
41
42 /// Returns a directory suitable for storing user-specific data
43 Path get_user_data_dir(const std::string &appname);
44
45 /// Returns a directory containing system-wide configuration
46 Path get_sys_conf_dir(const std::string &argv0);
47
48 /// Returns a directory containing immutable system-wide data
49 Path get_sys_data_dir(const std::string &argv0, const std::string &appname);
50
51 /// Returns a directory containing system-wide architecture-specific files
52 Path get_sys_lib_dir(const std::string &argv0, const std::string &appname);
53
54 /// Changes the current working directory
55 void chdir(const Path &);
56
57 } // namespace FS
58 } // namespace Msp
59
60 #endif