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

#include "ZipDirFs/Containers/EntryIterator.h"
#include <ctime>
#include <filesystem>
#include <functional>
#include <sys/stat.h>

namespace ZipDirFs::Utilities
{
	namespace fs = std::filesystem;
	using Containers::EntryIterator;

	/**
	 * @brief Global file system call wrapper
	 * @remarks Used to help in executing unit tests.
	 * @authors Pierrick Caillon <pierrick.caillon+zipdirfs@megami.fr>
	 */
	class FileSystem
	{
	public:
		static void reset();
		static std::function<fs::file_time_type(const fs::path&)> last_write_time;
		static std::function<EntryIterator(const fs::path&)> directory_iterator_from_path;
		static std::function<EntryIterator()> directory_iterator_end;
		static std::function<fs::file_status(const fs::path&)> status;

		template <typename Func>
		inline static void assign(std::function<Func>& t, Func* f)
		{
			t = std::function<Func>(f);
		}

	private:
		FileSystem();
	};

} // namespace ZipDirFs::Utilities

#endif // ZIPDIRFS_UTILITIES_FILESYSTEM_H
