#pragma once
#include "common/entry_index.h"
#include "root.h"
#include "tvfs_root.h"
#include <memory>
#include <span>
#include <string>
#include <unordered_map>
#include <vector>
namespace whiteout::interfaces {
class WorkerPool;
}
namespace whiteout::storages::casc {
class WowTvfsRoot final : public RootManifest {
public:
static bool looksLikeWowTvfs(const TvfsRoot& tvfs);
static std::unique_ptr<WowTvfsRoot> create(std::unique_ptr<TvfsRoot> tvfs,
interfaces::WorkerPool* pool = nullptr,
std::span<const u8> listfile = {});
std::vector<const RootEntry*> findByPath(const std::string& path) const override;
std::vector<const RootEntry*> findByFileDataId(
u32 fileDataId, FileIdHint hint = FileIdHint::None) const override;
bool hasFileDataId(u32 fileDataId, FileIdHint hint = FileIdHint::None) const override;
RootFormat format() const override {
return RootFormat::WowTvfs;
}
protected:
const std::vector<RootEntry>& entries() const override;
std::vector<RootEntry>& mutableEntries() override;
private:
std::unique_ptr<TvfsRoot> m_tvfs;
std::vector<RootEntry> m_entries;
EntryIndex<u32> m_byFileDataId;
EntryIndex<std::string> m_byPath;
void buildIndex(interfaces::WorkerPool* pool);
};
}