mirror of https://github.com/OpenMW/openmw.git
OpenCS: use the new VFS, restored resource tables
parent
49c2da27b3
commit
40fc097722
@ -0,0 +1,42 @@
|
||||
#include "registerarchives.hpp"
|
||||
|
||||
#include <components/vfs/manager.hpp>
|
||||
#include <components/vfs/bsaarchive.hpp>
|
||||
#include <components/vfs/filesystemarchive.hpp>
|
||||
|
||||
namespace VFS
|
||||
{
|
||||
|
||||
void registerArchives(VFS::Manager *vfs, const Files::Collections &collections, const std::vector<std::string> &archives, bool useLooseFiles)
|
||||
{
|
||||
const Files::PathContainer& dataDirs = collections.getPaths();
|
||||
|
||||
if (useLooseFiles)
|
||||
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter)
|
||||
{
|
||||
// Last data dir has the highest priority
|
||||
vfs->addArchive(new FileSystemArchive(iter->string()));
|
||||
}
|
||||
|
||||
for (std::vector<std::string>::const_iterator archive = archives.begin(); archive != archives.end(); ++archive)
|
||||
{
|
||||
if (collections.doesExist(*archive))
|
||||
{
|
||||
// Last BSA has the highest priority
|
||||
const std::string archivePath = collections.getPath(*archive).string();
|
||||
std::cout << "Adding BSA archive " << archivePath << std::endl;
|
||||
|
||||
vfs->addArchive(new BsaArchive(archivePath));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::stringstream message;
|
||||
message << "Archive '" << *archive << "' not found";
|
||||
throw std::runtime_error(message.str());
|
||||
}
|
||||
}
|
||||
|
||||
vfs->buildIndex();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#ifndef OPENMW_COMPONENTS_VFS_REGISTER_ARCHIVES_H
|
||||
#define OPENMW_COMPONENTS_VFS_REGISTER_ARCHIVES_H
|
||||
|
||||
#include <components/files/collections.hpp>
|
||||
|
||||
namespace VFS
|
||||
{
|
||||
class Manager;
|
||||
|
||||
/// @brief Register BSA and file system archives based on the given OpenMW configuration.
|
||||
void registerArchives (VFS::Manager* vfs, const Files::Collections& collections,
|
||||
const std::vector<std::string>& archives, bool useLooseFiles);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue