Re-index BSAs

experimental
Kyle Cooley 7 years ago
parent d7744e8b16
commit 7914fd5c9c

@ -21,8 +21,8 @@ namespace VFS
public:
virtual ~Archive() {}
/// Clears cached data for archives that may change.
virtual void resetIfNotStatic(){};
/// Clears cached data.
virtual void reset() = 0;
/// List all resources contained in this archive, and run the resource names through the given normalize function.
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char)) = 0;

@ -5,14 +5,15 @@ namespace VFS
BsaArchive::BsaArchive(const std::string &filename)
: mFileName(filename)
{
mFile.open(filename);
load();
}
const Bsa::BSAFile::FileList &filelist = mFile.getList();
for(Bsa::BSAFile::FileList::const_iterator it = filelist.begin();it != filelist.end();++it)
void BsaArchive::reset()
{
mResources.push_back(BsaArchiveFile(&*it, &mFile));
}
mResources.clear();
load();
}
void BsaArchive::listResources(std::map<std::string, File *> &out, char (*normalize_function)(char))
@ -26,6 +27,17 @@ void BsaArchive::listResources(std::map<std::string, File *> &out, char (*normal
}
}
void BsaArchive::load()
{
mFile.open(mFileName);
const Bsa::BSAFile::FileList &filelist = mFile.getList();
for(Bsa::BSAFile::FileList::const_iterator it = filelist.begin();it != filelist.end();++it)
{
mResources.push_back(BsaArchiveFile(&*it, &mFile));
}
}
// ------------------------------------------------------------------------------
BsaArchiveFile::BsaArchiveFile(const Bsa::BSAFile::FileStruct *info, Bsa::BSAFile* bsa)

@ -24,9 +24,14 @@ namespace VFS
public:
BsaArchive(const std::string& filename);
virtual void reset();
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));
private:
void load();
std::string mFileName;
Bsa::BSAFile mFile;
std::vector<BsaArchiveFile> mResources;

@ -12,7 +12,7 @@ namespace VFS
}
void FileSystemArchive::resetIfNotStatic()
void FileSystemArchive::reset()
{
mIndex.clear();
mBuiltIndex = false;

@ -23,7 +23,7 @@ namespace VFS
public:
FileSystemArchive(const std::string& path);
virtual void resetIfNotStatic();
virtual void reset();
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));

@ -60,7 +60,7 @@ namespace VFS
void Manager::rebuildIndex()
{
for (std::vector<Archive*>::const_iterator it = mArchives.begin(); it != mArchives.end(); ++it)
(*it)->resetIfNotStatic();
(*it)->reset();
buildIndex();
}

Loading…
Cancel
Save