42 lines
973 B
C++
42 lines
973 B
C++
|
|
#include "LoadFile.h"
|
|
|
|
using namespace std;
|
|
|
|
/* The data section is generated by a perl script. The contents of the
|
|
* included file are part of this logical program unit, which is why it
|
|
* is directly included instead of compiling it separately.
|
|
*/
|
|
#include "LoadFile-gen.inc"
|
|
|
|
LoadFile::LoadFile()
|
|
{
|
|
for (unsigned int i = 0;
|
|
i < sizeof(LoadFileData)/sizeof(LoadFileData[0]);
|
|
i++)
|
|
{
|
|
m_filemap[LoadFileData[i].filename] = &LoadFileData[i];
|
|
}
|
|
}
|
|
|
|
FileLoader::Buffer LoadFile::load(const FileLoader::Path & path)
|
|
{
|
|
map<string, fileref_t *>::iterator it = m_filemap.find(path.shortPath);
|
|
|
|
if (it == m_filemap.end())
|
|
return Buffer(0);
|
|
|
|
return Buffer((char *) it->second->data, it->second->length);
|
|
}
|
|
|
|
int LoadFile::getSize(const FileLoader::Path & path)
|
|
{
|
|
map<string, fileref_t *>::iterator it = m_filemap.find(path.shortPath);
|
|
|
|
if (it == m_filemap.end())
|
|
return 0;
|
|
|
|
return it->second->length;
|
|
}
|
|
|