6 #include <msp/time/timestamp.h>
20 typedef uint64_t FileSize;
23 Holds file information.
37 FileType type = UNKNOWN;
39 FileSize alloc_size = 0;
40 Time::TimeStamp mtime;
41 mutable OwnerInfo owner_info;
42 Private *priv = nullptr;
47 Stat &operator=(const Stat &);
50 FileType get_type() const { return type; }
51 bool is_regular() const { return type==REGULAR; }
52 bool is_directory() const { return type==DIRECTORY; }
53 bool is_symlink() const { return type==SYMLINK; }
54 FileSize get_size() const { return size; }
55 FileSize get_alloc_size() const { return alloc_size; }
56 const Time::TimeStamp &get_modify_time() const { return mtime; }
57 const std::string &get_owner() const;
58 const std::string &get_group() const;
60 operator bool() const { return exists; }
62 /// Returns a Stat object describing a file.
63 static Stat stat(const Path &);
64 static Stat lstat(const Path &);
67 /// Convenience wrapper for Stat::stat
68 inline Stat stat(const Path &path)
69 { return Stat::stat(path); }
71 /// Convenience wrapper for Stat::lstat
72 inline Stat lstat(const Path &path)
73 { return Stat::lstat(path); }
75 /// Tests for existence of a file
76 bool exists(const Path &path);
78 /// Tests whether a path refers to an existing regular file
79 inline bool is_reg(const Path &path)
80 { return stat(path).is_regular(); }
82 /// Tests whether a path refers to an existing directory
83 inline bool is_dir(const Path &path)
84 { return stat(path).is_directory(); }
86 /// Tests whether a path refers to a symbolic link
87 inline bool is_link(const Path &path)
88 { return lstat(path).is_symlink(); }