Something went wrong. Try again.
OpenMW is an open implementation of the Morrowind engine
Something went wrong. Try again.
1.8 kB · 55 lines
C++
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556#include "registerarchives.hpp"
#include <filesystem>#include <set>#include <stdexcept>
#include <components/debug/debuglog.hpp>
#include <components/vfs/bsaarchive.hpp>#include <components/vfs/filesystemarchive.hpp>#include <components/vfs/manager.hpp>
namespace VFS{
void registerArchives(VFS::Manager* vfs, const Files::Collections& collections, const std::vector<std::string>& archives, bool useLooseFiles, const ToUTF8::StatelessUtf8Encoder* encoder) { const Files::PathContainer& dataDirs = collections.getPaths();
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 auto archivePath = collections.getPath(*archive); Log(Debug::Info) << "Adding BSA archive " << archivePath; vfs->addArchive(makeBsaArchive(archivePath, encoder)); } else { throw std::runtime_error("Archive '" + *archive + "' not found"); } }
if (useLooseFiles) { std::set<std::filesystem::path> seen; for (const auto& dataDir : dataDirs) { if (seen.insert(dataDir).second) { Log(Debug::Info) << "Adding data directory " << dataDir; // Last data dir has the highest priority vfs->addArchive(std::make_unique<FileSystemArchive>(dataDir)); } else Log(Debug::Info) << "Ignoring duplicate data directory " << dataDir; } }
vfs->buildIndex(); }
}