#pragma once

#include "fs/IPack.h"
#include "fs/Api.h"

namespace fs
{
//////////////////////////////////////////////////////////////////////////

class FS_API FolderPack : virtual public IPack
{
public:
	explicit FolderPack(AbsPathView location);
	FolderPack(tl::lent_ref<IFilesystem> filesystem, AbsPathView location);

	~FolderPack() override = default;

	OpenSourceResult openSource(AbsPathView path, SourceFlags flags = SourceFlags()) const override;
	OpenStreamSourceResult openStreamSource(AbsPathView path, SourceFlags flags = SourceFlags()) const override;
	OpenMapSourceResult openMapSource(AbsPathView path, MapView mapView = MapView(), SourceFlags flags = SourceFlags()) const override;

	IsFileResult isFile(AbsPathView path) const override;
	IsFolderResult isFolder(AbsPathView path) const override;
	ExistsResult exists(AbsPathView path) const override;

	GetStatResult getStat(AbsPathView path) const override;

	cppcoro::generator<EnumerateEntry> enumerate(AbsPath path) const override;
	cppcoro::generator<EnumerateEntry> enumerateRecursively(AbsPath path) const override;

	ConvertToNativePathResult convertToNativePath(AbsPathView path) const override;

protected:
	AbsPath convertToUnderlyingPath(AbsPathView path) const;
	tl::lent_ref<IFilesystem> m_filesystem;
	AbsPath m_location;
};

//////////////////////////////////////////////////////////////////////////
}
