aboutsummaryrefslogtreecommitdiff
path: root/src/stat.h
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2020-05-10 16:58:05 +0300
committerromkatv <roman.perepelitsa@gmail.com>2020-05-10 16:58:05 +0300
commit1531d6e5439daae01627b2645684876b75eaf5eb (patch)
tree05ed820f16dbb04be4b4b8ec3055f93431518773 /src/stat.h
Squashed 'gitstatus/' content from commit 6b9ba17
git-subtree-dir: gitstatus git-subtree-split: 6b9ba179c6655286c4c399e7926d5098dd6bd706
Diffstat (limited to 'src/stat.h')
-rw-r--r--src/stat.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/stat.h b/src/stat.h
new file mode 100644
index 00000000..4f3195a7
--- /dev/null
+++ b/src/stat.h
@@ -0,0 +1,23 @@
+#ifndef ROMKATV_GITSTATUS_STAT_H_
+#define ROMKATV_GITSTATUS_STAT_H_
+
+#include <sys/stat.h>
+
+namespace gitstatus {
+
+inline const struct timespec& MTim(const struct stat& s) {
+#ifdef __APPLE__
+ return s.st_mtimespec;
+#else
+ return s.st_mtim;
+#endif
+}
+
+inline bool StatEq(const struct stat& x, const struct stat& y) {
+ return MTim(x).tv_sec == MTim(y).tv_sec && MTim(x).tv_nsec == MTim(y).tv_nsec &&
+ x.st_size == y.st_size && x.st_ino == y.st_ino && x.st_mode == y.st_mode;
+}
+
+} // namespace gitstatus
+
+#endif // ROMKATV_GITSTATUS_STAT_H_