/*
 * Copyright © 2021-2026 Pierrick Caillon <pierrick.caillon+zipdirfs@megami.fr>
 */
// ReSharper disable CppMemberFunctionMayBeStatic
#ifndef ZIPDIRFS_FUSE_ZIPTIMEPOLICY_H
#define ZIPDIRFS_FUSE_ZIPTIMEPOLICY_H

#include <ctime>

namespace ZipDirFs::Fuse
{
	using std::time_t;

	/**
	 * @brief A fusekit time policy for zip archive entry
	 * @authors Pierrick Caillon <pierrick.caillon+zipdirfs@megami.fr>
	 * @tparam Derived Recursive templating parameter.
	 */
	template <class Derived>
	// ReSharper disable once CppPolymorphicClassWithNonVirtualPublicDestructor
	struct ZipTimePolicy
	{
		[[nodiscard]] timespec change_time() const { return timespec{this->getParentModificationTime(), 0}; }
		[[nodiscard]] timespec access_time() const { return timespec{this->getModificationTime(), 0}; }
		[[nodiscard]] timespec modification_time() const { return timespec{this->getModificationTime(), 0}; }
		void update(int) {}
		[[nodiscard]] virtual std::time_t getParentModificationTime() const = 0;
		[[nodiscard]] virtual std::time_t getModificationTime() const = 0;
	};
} // namespace ZipDirFs::Fuse

#endif // ZIPDIRFS_FUSE_ZIPTIMEPOLICY_H
