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

#include "ZipDirFs/Components/ZipFileChanged.h"
#include "ZipDirFs/Fuse/ZipFileBuffer.h"
#include "ZipDirFs/Fuse/ZipTimePolicy.h"
#include "ZipDirFs/Utilities/DefaultPermission.h"
#include <filesystem>
#include <fusekit/basic_file.h>
#include <fusekit/no_xattr.h>
#include <memory>

namespace ZipDirFs::Fuse
{
	using namespace fusekit;

	/**
	 * @brief A file entry representing a file in a zip archive
	 * @authors Pierrick Caillon <pierrick.caillon+zipdirfs@megami.fr>
	 */
	struct ZipFile : basic_file<DefaultZipFileBuffer, ZipTimePolicy,
						 Utilities::DefaultFilePermission, no_xattr>
	{
		ZipFile(std::filesystem::path zip, std::string file,
			std::shared_ptr<Containers::Helpers::Changed> rootChanged);
		[[nodiscard]] std::time_t getParentModificationTime() const override;
		[[nodiscard]] std::time_t getModificationTime() const override;
		[[nodiscard]] std::shared_ptr<Zip::Entry> entry() const override;
		[[nodiscard]] off_t entrySize() const override;

	private:
		const std::filesystem::path zip;
		const std::string file;
		Components::ZipFileChanged changed;
		std::shared_ptr<Containers::Helpers::Changed> _rootChanged;
		const off_t size;
	};
} // namespace ZipDirFs::Fuse

#endif // ZIPDIRFS_FUSE_NATIVESYMLINK_H
