/*
 * Copyright © 2020-2026 Pierrick Caillon <pierrick.caillon+zipdirfs@megami.fr>
 */
#ifndef ZIPDIRFS_COMPONENTS_ZIPFILECHANGED_H
#define ZIPDIRFS_COMPONENTS_ZIPFILECHANGED_H

#include "ZipDirFs/Containers/Helpers/Changed.h"
#include <bitset>
#include <filesystem>
#include <string>

namespace ZipDirFs::Components
{
	namespace fs = std::filesystem;

	/**
	 * @brief A @link ZipDirFs::Container::Helpers::Changed Changed @endlink helper for entry in zip archive
	 * @authors Pierrick Caillon <pierrick.caillon+zipdirfs@megami.fr>
	 */
	class ZipFileChanged : public Containers::Helpers::Changed
	{
	public:
		ZipFileChanged(const fs::path&, const std::string&);
		bool operator()() override;
		operator FileTime() const override;
		static FileTime getTime(const fs::path&, const std::string&);

	protected:
		const fs::path& path;
		const std::string& item;
		FileTime lastPathChanged;
		FileTime lastItemChanged;
		std::bitset<2> state;
	};

} // namespace ZipDirFs::Components

#endif // ZIPDIRFS_COMPONENTS_ZIPFILECHANGED_H
