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

#include <fusekit/entry.h>
#include <memory>

namespace ZipDirFs::Fuse
{
	/**
	 * @brief A fusekit entry which proxy calls to another and can be changed
	 * @remarks Mainly used to bootstrap the daemon.
	 * @authors Pierrick Caillon <pierrick.caillon+zipdirfs@megami.fr>
	 */
	class EntryProxy : public fusekit::entry
	{
	public:
		EntryProxy() = default;
		EntryProxy& operator=(std::unique_ptr<entry>&& target);
		EntryProxy& operator=(EntryProxy&& proxy) noexcept ;
		entry* child(const char*) override;
		int stat(struct stat&) override;
		int access(int) override;
		int chmod(mode_t) override;
		int open(fuse_file_info&) override;
		int release(fuse_file_info&) override;
		int read(char*, size_t, off_t, fuse_file_info&) override;
		int write(const char*, size_t, off_t, fuse_file_info&) override;
		int opendir(fuse_file_info&) override;
		int readdir(void*, fuse_fill_dir_t, off_t, fuse_file_info&) override;
		int releasedir(fuse_file_info&) override;
		int mknod(const char*, mode_t, dev_t) override;
		int unlink(const char*) override;
		int mkdir(const char*, mode_t) override;
		int rmdir(const char*) override;
		int flush(fuse_file_info&) override;
		int truncate(off_t) override;
		int utimens(const timespec[2]) override;
		int readlink(char*, size_t) override;
		int symlink(const char*, const char*) override;
		int setxattr(const char*, const char*, size_t, int) override;
		int getxattr(const char*, char*, size_t) override;
		int listxattr(char*, size_t) override;
		int removexattr(const char*) override;

	private:
		std::unique_ptr<entry> target;
	};
} // namespace ZipDirFs::Fuse

#endif // ZIPDIRFS_FUSE_PROXYDIRECTORY_H
