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