From afe886a69b59cbe1d9a8cd9a908b6a25d1f5e653 Mon Sep 17 00:00:00 2001 From: Luis Michaelis Date: Fri, 6 Dec 2024 14:19:24 +0100 Subject: [PATCH] feat(Vfs): allow setting Vfs save date --- include/zenkit/Vfs.hh | 2 +- src/Vfs.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/zenkit/Vfs.hh b/include/zenkit/Vfs.hh index 60805974..fbe8beb1 100644 --- a/include/zenkit/Vfs.hh +++ b/include/zenkit/Vfs.hh @@ -193,7 +193,7 @@ namespace zenkit { /// \return The node with the given name or `nullptr` if no node with the given name was found. [[nodiscard]] ZKAPI VfsNode* find(std::string_view name) noexcept; - ZKAPI void save(Write* w, GameVersion version) const; + ZKAPI void save(Write* w, GameVersion version, time_t unix_t = 0) const; private: ZKINT void mount_disk(std::byte const* buf, std::size_t size, VfsOverwriteBehavior overwrite); diff --git a/src/Vfs.cc b/src/Vfs.cc index 54782223..6124226e 100644 --- a/src/Vfs.cc +++ b/src/Vfs.cc @@ -286,7 +286,7 @@ namespace zenkit { return dos; } - void Vfs::save(Write* w, GameVersion version) const { + void Vfs::save(Write* w, GameVersion version, time_t unix_t) const { std::vector catalog; auto write_catalog = Write::to(&catalog); @@ -360,7 +360,7 @@ namespace zenkit { w->write_string(version == GameVersion::GOTHIC_1 ? VFS_DISK_SIGNATURE_G1 : VFS_DISK_SIGNATURE_G2); w->write_uint(index); w->write_uint(files); - w->write_uint(vfs_unix_to_dos_time(time(nullptr))); + w->write_uint(unix_t == 0 ? vfs_unix_to_dos_time(time(nullptr)) : vfs_unix_to_dos_time(time(&unix_t))); w->write_uint(off + catalog.size()); w->write_uint(header_size); w->write_uint(80);