ewmscp  ..
genericStat.h
Go to the documentation of this file.
1 #ifndef __genericStat_h_
2 #define __genericStat_h_
3 #include <chrono>
4 #include <string>
5 #include <sys/types.h>
6 struct stat;
12 class genericStat {
13  public:
14  typedef std::chrono::system_clock clock_type;
15  dev_t device;
16  size_t size;
17  size_t sizeOnDisk;
18  size_t blksize;
19  clock_type::time_point aTime;
20  clock_type::time_point mTime;
21  clock_type::duration timeResolution;
22  mode_t mode;
23  uid_t ownerUid;
24  gid_t ownerGid;
25  genericStat(const struct stat& statBuf, const clock_type::duration& aTimeResolution);
26  genericStat(const struct stat64& statBuf, const clock_type::duration& aTimeResolution);
27  genericStat();
28  private:
29  static void chronoToTimespec(struct timespec& spec, const clock_type::time_point& Chrono);
30  static void chronoToTimeval(struct timeval& spec, const clock_type::time_point& Chrono);
31  static void chronoToString(std::string& str, const clock_type::time_point& Chrono);
32  public:
33  void getAtime(struct timespec& spec) const;
34  void getMtime(struct timespec& spec) const;
35  void getAtime(struct timeval& spec) const;
36  void getMtime(struct timeval& spec) const;
37  void getAtime(std::string& spec) const;
38  void getMtime(std::string& spec) const;
39  clock_type::time_point getMtime() const;
40  bool isNewerThan(const genericStat& that) const;
41  bool isSameMtimeAs(const genericStat& that) const;
42  bool isDir() const;
43  bool isLink() const;
44  bool isRegularFile() const;
45 };
46 std::ostream& operator<<(std::ostream& stream, const genericStat& aStat);
47 
48 #endif
genericStat::ownerGid
gid_t ownerGid
Definition: genericStat.h:24
genericStat::mode
mode_t mode
Definition: genericStat.h:22
genericStat::getAtime
void getAtime(struct timespec &spec) const
Definition: genericStat.cpp:62
genericStat::clock_type
std::chrono::system_clock clock_type
Definition: genericStat.h:14
genericStat
generic stat abstraction class Used to abstract the variants of the stat structure.
Definition: genericStat.h:12
genericStat::isLink
bool isLink() const
Definition: genericStat.cpp:95
genericStat::mTime
clock_type::time_point mTime
Definition: genericStat.h:20
genericStat::isRegularFile
bool isRegularFile() const
Definition: genericStat.cpp:98
genericStat::sizeOnDisk
size_t sizeOnDisk
Definition: genericStat.h:17
genericStat::isSameMtimeAs
bool isSameMtimeAs(const genericStat &that) const
Definition: genericStat.cpp:87
genericStat::aTime
clock_type::time_point aTime
Definition: genericStat.h:19
genericStat::isDir
bool isDir() const
Definition: genericStat.cpp:92
genericStat::blksize
size_t blksize
Definition: genericStat.h:18
genericStat::size
size_t size
Definition: genericStat.h:16
genericStat::chronoToTimeval
static void chronoToTimeval(struct timeval &spec, const clock_type::time_point &Chrono)
Definition: genericStat.cpp:43
genericStat::device
dev_t device
Definition: genericStat.h:15
genericStat::genericStat
genericStat()
genericStat::getMtime
clock_type::time_point getMtime() const
Definition: genericStat.cpp:80
genericStat::timeResolution
clock_type::duration timeResolution
Definition: genericStat.h:21
genericStat::isNewerThan
bool isNewerThan(const genericStat &that) const
Definition: genericStat.cpp:84
operator<<
std::ostream & operator<<(std::ostream &stream, const genericStat &aStat)
Definition: genericStat.cpp:102
genericStat::ownerUid
uid_t ownerUid
Definition: genericStat.h:23
genericStat::chronoToString
static void chronoToString(std::string &str, const clock_type::time_point &Chrono)
Definition: genericStat.cpp:47
genericStat::chronoToTimespec
static void chronoToTimespec(struct timespec &spec, const clock_type::time_point &Chrono)
Definition: genericStat.cpp:39