1 #ifndef BLANK_IO_FILESYSTEM_HPP_
2 #define BLANK_IO_FILESYSTEM_HPP_
10 /// check if give path points to an existing directory
11 bool is_dir(const char *);
12 inline bool is_dir(const std::string &s) {
13 return is_dir(s.c_str());
15 /// check if give path points to an existing file
16 bool is_file(const char *);
17 inline bool is_file(const std::string &s) {
18 return is_file(s.c_str());
20 /// get timestamp of last modification
21 std::time_t file_mtime(const char *);
22 inline std::time_t file_mtime(const std::string &s) {
23 return file_mtime(s.c_str());
26 /// create given directory
27 /// @return true if the directory was created
28 /// the directory might already exist, see errno
29 bool make_dir(const char *);
30 inline bool make_dir(const std::string &s) {
31 return make_dir(s.c_str());
33 /// create given directory and all parents
34 /// @return true if the directory was created or already exists
35 bool make_dirs(const std::string &);
38 /// @return true on success
39 bool remove_file(const std::string &);
40 /// recursively remove given directory
41 /// may leave the directory partially removed on failure
42 /// @return true if the directory was completely removed
43 bool remove_dir(const std::string &);
46 /// Create a temporary directory with lifetime tie to the instance's.
47 /// Note that the directory may survive its object if removal fails
48 /// for any reason, e.g. another process changing permissions.
55 TempDir(const TempDir &) = delete;
56 TempDir &operator =(const TempDir &) = delete;
59 const std::string &Path() const noexcept { return path; }