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

#include "ZipDirFs/Components/NativeChanged.h"
#include "ZipDirFs/Fuse/NativeTimePolicy.h"
#include "ZipDirFs/Utilities/DefaultPermission.h"
#include <filesystem>
#include <fusekit/basic_symlink.h>
#include <fusekit/no_xattr.h>
#include <memory>

namespace ZipDirFs::Fuse
{
	namespace fs = std::filesystem;
	using namespace fusekit;

	/**
	 * @brief A file entry representing a symlink to a real filesystem file
	 * @authors Pierrick Caillon <pierrick.caillon+zipdirfs@megami.fr>
	 */
	struct NativeSymlink
		: basic_symlink<NativeTimePolicy, Utilities::DefaultLinkPermission, no_xattr>
	{
		NativeSymlink(const fs::path& path);
		[[nodiscard]] std::time_t getChangeTime() const override;
		[[nodiscard]] std::time_t getModificationTime() const override;

	private:
		const fs::path path;
		std::unique_ptr<std::string> target;
		Components::NativeChanged changed;
	};
} // namespace ZipDirFs::Fuse

#endif // ZIPDIRFS_FUSE_NATIVESYMLINK_H
