aboutsummaryrefslogtreecommitdiff
path: root/tests/dir-iterator/driver.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-12-23 22:57:27 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2023-01-09 11:33:08 +0300
commit31b74a064317186d7e891207de803b9d6dfb2642 (patch)
tree5c38a5728d72168a8c9218befaa2a6e42674ff6e /tests/dir-iterator/driver.cxx
parentbded624bacbc284e523e44d73572a4f60d817b03 (diff)
Add mtime() and atime() to dir_entry
Diffstat (limited to 'tests/dir-iterator/driver.cxx')
-rw-r--r--tests/dir-iterator/driver.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/dir-iterator/driver.cxx b/tests/dir-iterator/driver.cxx
index 92b0b57..c9f7218 100644
--- a/tests/dir-iterator/driver.cxx
+++ b/tests/dir-iterator/driver.cxx
@@ -7,6 +7,7 @@
#include <libbutl/path.hxx>
#include <libbutl/path-io.hxx>
#include <libbutl/utility.hxx> // operator<<(ostream, exception)
+#include <libbutl/timestamp.hxx>
#include <libbutl/filesystem.hxx>
#undef NDEBUG
@@ -38,6 +39,10 @@ operator<< (ostream& os, entry_type e)
// Ignore dangling symlinks, rather than fail trying to obtain the target
// type.
//
+// -d
+// Detect dangling symlinks, rather than fail trying to obtain the target
+// type.
+//
int
main (int argc, const char* argv[])
{
@@ -80,9 +85,30 @@ main (int argc, const char* argv[])
detect_dangling ? dir_iterator::detect_dangling :
dir_iterator::no_follow)))
{
+ timestamp mt (de.mtime ());
+ timestamp at (de.atime ());
+
entry_type lt (de.ltype ());
entry_type t (lt == entry_type::symlink ? de.type () : lt);
+
const path& p (de.path ());
+ path fp (de.base () / p);
+
+ entry_time et (t == entry_type::directory
+ ? dir_time (path_cast<dir_path> (fp))
+ : file_time (fp));
+
+ if (mt != timestamp_unknown)
+ assert (mt == et.modification);
+
+ if (at != timestamp_unknown)
+ assert (mt == et.access);
+
+ if (de.mtime () != timestamp_unknown)
+ assert (de.mtime () == et.modification);
+
+ if (de.atime () != timestamp_unknown)
+ assert (de.atime () == et.access);
if (verbose)
{