mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-15 15:26:19 -04:00
Add create timestamp
This commit is contained in:
parent
480a2f839b
commit
f9743537ce
@ -24,6 +24,7 @@
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <numeric>
|
||||
#include <ostream>
|
||||
|
||||
@ -574,6 +575,13 @@ void metadata_<LoggerPolicy>::dump(
|
||||
os << "created by: " << *version << std::endl;
|
||||
}
|
||||
|
||||
if (auto ts = meta_.create_timestamp()) {
|
||||
time_t tp = *ts;
|
||||
std::string str(20, '\0');
|
||||
std::strftime(str.data(), str.size(), "%F %T", std::localtime(&tp));
|
||||
os << "created on: " << str << std::endl;
|
||||
}
|
||||
|
||||
if (detail_level > 0) {
|
||||
os << "block size: " << stbuf.f_bsize << std::endl;
|
||||
os << "inode count: " << stbuf.f_files << std::endl;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <deque>
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
@ -726,6 +727,7 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
|
||||
mv2.total_hardlink_size_ref() = prog.hardlink_size;
|
||||
mv2.options_ref() = fsopts;
|
||||
mv2.dwarfs_version_ref() = std::string("libdwarfs ") + PRJ_GIT_ID;
|
||||
mv2.create_timestamp_ref() = std::time(nullptr);
|
||||
|
||||
auto [schema, data] = metadata_v2::freeze(mv2);
|
||||
|
||||
|
@ -238,6 +238,6 @@ struct metadata {
|
||||
// version
|
||||
22: optional string dwarfs_version,
|
||||
|
||||
// TODO: add timestamp
|
||||
// 21: optional UInt64 timestamp,
|
||||
// timestamp
|
||||
23: optional UInt64 create_timestamp,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user