]> git.localhorst.tv Git - blobs.git/blob - src/io/filesystem.hpp
more stuff from blank
[blobs.git] / src / io / filesystem.hpp
1 #ifndef BLOBS_IO_FILESYSTEM_HPP_
2 #define BLOBS_IO_FILESYSTEM_HPP_
3
4 #include <ctime>
5 #include <string>
6
7
8 namespace blobs {
9 namespace io {
10
11 /// check if give path points to an existing directory
12 bool is_dir(const char *);
13 inline bool is_dir(const std::string &s) {
14         return is_dir(s.c_str());
15 }
16 /// check if give path points to an existing file
17 bool is_file(const char *);
18 inline bool is_file(const std::string &s) {
19         return is_file(s.c_str());
20 }
21 /// get timestamp of last modification
22 std::time_t file_mtime(const char *);
23 inline std::time_t file_mtime(const std::string &s) {
24         return file_mtime(s.c_str());
25 }
26
27 /// create given directory
28 /// @return true if the directory was created
29 ///         the directory might already exist, see errno
30 bool make_dir(const char *);
31 inline bool make_dir(const std::string &s) {
32         return make_dir(s.c_str());
33 }
34 /// create given directory and all parents
35 /// @return true if the directory was created or already exists
36 bool make_dirs(const std::string &);
37
38 /// remove given file
39 /// @return true on success
40 bool remove_file(const std::string &);
41 /// recursively remove given directory
42 /// may leave the directory partially removed on failure
43 /// @return true if the directory was completely removed
44 bool remove_dir(const std::string &);
45
46 }
47 }
48
49 #endif