2015-02-26 04:57:28 +01:00
|
|
|
#pragma once
|
|
|
|
#include "FileHandle.hpp"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
class FileIndex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
struct IndexData
|
|
|
|
{
|
|
|
|
/// Lowercase identifying filename
|
|
|
|
std::string filename;
|
|
|
|
/// Original filename
|
|
|
|
std::string originalName;
|
|
|
|
/// Containing directory
|
|
|
|
std::string directory;
|
|
|
|
/// The archive filename (if applicable)
|
|
|
|
std::string archive;
|
|
|
|
};
|
|
|
|
|
2015-03-06 02:40:29 +01:00
|
|
|
/**
|
|
|
|
* Adds the files contained within the given directory tree to the
|
|
|
|
* file index.
|
|
|
|
*/
|
|
|
|
void indexTree(const std::string& root);
|
|
|
|
|
2015-02-26 04:57:28 +01:00
|
|
|
/**
|
|
|
|
* Adds the files contained within the given Archive file to the
|
|
|
|
* file index.
|
|
|
|
*/
|
|
|
|
void indexArchive(const std::string& archive);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the file identified by filename is found within
|
|
|
|
* the file index. If the file is found, the filedata parameter
|
|
|
|
* is populated.
|
|
|
|
*/
|
|
|
|
bool findFile(const std::string& filename, IndexData& filedata);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a FileHandle for the file if it can be found in the
|
|
|
|
* file index, otherwise an empty FileHandle is returned.
|
|
|
|
*/
|
|
|
|
FileHandle openFile(const std::string& filename);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::map<std::string, IndexData> files;
|
|
|
|
};
|