1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-13 06:12:46 +01:00
openrw/rwengine/include/core/FileIndex.hpp
Daniel Evans abf43f07c8 New File handling implementation
- move FileHandle into a separate header
- Implement FileIndex, a system to normalize filenames and sources
2015-04-03 03:04:50 +01:00

50 lines
1.1 KiB
C++

#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;
};
/**
* Adds the files contained within the given directory to the
* file index.
*/
void indexDirectory(const std::string& directory);
/**
* 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;
};