mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 21:09:41 +00:00
VFS changes, one VFS and resource system per document.
Added ability to reset a VFS::Manager. Removed ability to rebuild the index for a VFS::Manager. Moved VFS creation to CSM::Data.
This commit is contained in:
parent
979b0d7211
commit
8c4b12a603
15 changed files with 61 additions and 88 deletions
|
@ -5,9 +5,6 @@
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <components/vfs/manager.hpp>
|
|
||||||
#include <components/vfs/registerarchives.hpp>
|
|
||||||
|
|
||||||
#include <components/fallback/validate.hpp>
|
#include <components/fallback/validate.hpp>
|
||||||
|
|
||||||
#include <components/nifosg/nifloader.hpp>
|
#include <components/nifosg/nifloader.hpp>
|
||||||
|
@ -33,11 +30,7 @@ CS::Editor::Editor ()
|
||||||
|
|
||||||
NifOsg::Loader::setShowMarkers(true);
|
NifOsg::Loader::setShowMarkers(true);
|
||||||
|
|
||||||
mVFS.reset(new VFS::Manager(mFsStrict));
|
mDocumentManager.setFileData(mFsStrict, config.first, config.second);
|
||||||
|
|
||||||
VFS::registerArchives(mVFS.get(), Files::Collections(config.first, !mFsStrict), config.second, true);
|
|
||||||
|
|
||||||
mDocumentManager.setVFS(mVFS.get());
|
|
||||||
|
|
||||||
mNewGame.setLocalData (mLocal);
|
mNewGame.setLocalData (mLocal);
|
||||||
mFileDialog.setLocalData (mLocal);
|
mFileDialog.setLocalData (mLocal);
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#ifndef CS_EDITOR_H
|
#ifndef CS_EDITOR_H
|
||||||
#define CS_EDITOR_H
|
#define CS_EDITOR_H
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <boost/interprocess/sync/file_lock.hpp>
|
#include <boost/interprocess/sync/file_lock.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
|
@ -30,11 +28,6 @@
|
||||||
|
|
||||||
#include "view/tools/merge.hpp"
|
#include "view/tools/merge.hpp"
|
||||||
|
|
||||||
namespace VFS
|
|
||||||
{
|
|
||||||
class Manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
class Document;
|
class Document;
|
||||||
|
@ -46,9 +39,6 @@ namespace CS
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// FIXME: should be moved to document, so we can have different resources for each opened project
|
|
||||||
std::unique_ptr<VFS::Manager> mVFS;
|
|
||||||
|
|
||||||
Files::ConfigurationManager mCfgMgr;
|
Files::ConfigurationManager mCfgMgr;
|
||||||
CSMPrefs::State mSettingsState;
|
CSMPrefs::State mSettingsState;
|
||||||
CSMDoc::DocumentManager mDocumentManager;
|
CSMDoc::DocumentManager mDocumentManager;
|
||||||
|
|
|
@ -269,13 +269,14 @@ void CSMDoc::Document::createBase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::Document::Document (VFS::Manager* vfs, const Files::ConfigurationManager& configuration,
|
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
||||||
const std::vector< boost::filesystem::path >& files, bool new_,
|
const std::vector< boost::filesystem::path >& files,bool new_,
|
||||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
||||||
const Fallback::Map* fallback,
|
const Fallback::Map* fallback,
|
||||||
ToUTF8::FromType encoding, CSMWorld::ResourcesManager& resourcesManager,
|
ToUTF8::FromType encoding,
|
||||||
const std::vector<std::string>& blacklistedScripts)
|
const std::vector<std::string>& blacklistedScripts,
|
||||||
: mVFS(vfs), mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, vfs, resourcesManager, fallback, resDir),
|
bool fsStrict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives)
|
||||||
|
: mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, fsStrict, dataPaths, archives, fallback, resDir),
|
||||||
mTools (*this, encoding),
|
mTools (*this, encoding),
|
||||||
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
||||||
(savePath.filename().string() + ".project")),
|
(savePath.filename().string() + ".project")),
|
||||||
|
@ -337,11 +338,6 @@ CSMDoc::Document::~Document()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const VFS::Manager *CSMDoc::Document::getVFS() const
|
|
||||||
{
|
|
||||||
return mVFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUndoStack& CSMDoc::Document::getUndoStack()
|
QUndoStack& CSMDoc::Document::getUndoStack()
|
||||||
{
|
{
|
||||||
return mUndoStack;
|
return mUndoStack;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <components/files/multidircollection.hpp>
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "../world/data.hpp"
|
#include "../world/data.hpp"
|
||||||
|
@ -59,7 +60,6 @@ namespace CSMDoc
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
VFS::Manager* mVFS;
|
|
||||||
boost::filesystem::path mSavePath;
|
boost::filesystem::path mSavePath;
|
||||||
std::vector<boost::filesystem::path> mContentFiles;
|
std::vector<boost::filesystem::path> mContentFiles;
|
||||||
bool mNew;
|
bool mNew;
|
||||||
|
@ -102,17 +102,15 @@ namespace CSMDoc
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Document (VFS::Manager* vfs, const Files::ConfigurationManager& configuration,
|
Document (const Files::ConfigurationManager& configuration,
|
||||||
const std::vector< boost::filesystem::path >& files, bool new_,
|
const std::vector< boost::filesystem::path >& files, bool new_,
|
||||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
||||||
const Fallback::Map* fallback,
|
const Fallback::Map* fallback, ToUTF8::FromType encoding,
|
||||||
ToUTF8::FromType encoding, CSMWorld::ResourcesManager& resourcesManager,
|
const std::vector<std::string>& blacklistedScripts,
|
||||||
const std::vector<std::string>& blacklistedScripts);
|
bool fsStrict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives);
|
||||||
|
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
const VFS::Manager* getVFS() const;
|
|
||||||
|
|
||||||
QUndoStack& getUndoStack();
|
QUndoStack& getUndoStack();
|
||||||
|
|
||||||
int getState() const;
|
int getState() const;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
|
|
||||||
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
||||||
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252), mVFS(NULL)
|
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252)
|
||||||
{
|
{
|
||||||
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ CSMDoc::Document *CSMDoc::DocumentManager::makeDocument (
|
||||||
const std::vector< boost::filesystem::path >& files,
|
const std::vector< boost::filesystem::path >& files,
|
||||||
const boost::filesystem::path& savePath, bool new_)
|
const boost::filesystem::path& savePath, bool new_)
|
||||||
{
|
{
|
||||||
return new Document (mVFS, mConfiguration, files, new_, savePath, mResDir, &mFallbackMap, mEncoding, mResourcesManager, mBlacklistedScripts);
|
return new Document (mConfiguration, files, new_, savePath, mResDir, &mFallbackMap, mEncoding, mBlacklistedScripts, mFsStrict, mDataPaths, mArchives);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::DocumentManager::insertDocument (CSMDoc::Document *document)
|
void CSMDoc::DocumentManager::insertDocument (CSMDoc::Document *document)
|
||||||
|
@ -127,8 +127,9 @@ void CSMDoc::DocumentManager::documentNotLoaded (Document *document, const std::
|
||||||
removeDocument (document);
|
removeDocument (document);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::DocumentManager::setVFS(VFS::Manager *vfs)
|
void CSMDoc::DocumentManager::setFileData(bool strict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives)
|
||||||
{
|
{
|
||||||
mResourcesManager.setVFS(vfs);
|
mFsStrict = strict;
|
||||||
mVFS = vfs;
|
mDataPaths = dataPaths;
|
||||||
|
mArchives = archives;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
|
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
#include <components/fallback/fallback.hpp>
|
#include <components/fallback/fallback.hpp>
|
||||||
|
#include <components/files/multidircollection.hpp>
|
||||||
#include "../world/resourcesmanager.hpp"
|
|
||||||
|
|
||||||
#include "loader.hpp"
|
#include "loader.hpp"
|
||||||
|
|
||||||
|
@ -39,9 +38,14 @@ namespace CSMDoc
|
||||||
QThread mLoaderThread;
|
QThread mLoaderThread;
|
||||||
Loader mLoader;
|
Loader mLoader;
|
||||||
ToUTF8::FromType mEncoding;
|
ToUTF8::FromType mEncoding;
|
||||||
CSMWorld::ResourcesManager mResourcesManager;
|
|
||||||
std::vector<std::string> mBlacklistedScripts;
|
std::vector<std::string> mBlacklistedScripts;
|
||||||
VFS::Manager* mVFS;
|
|
||||||
|
boost::filesystem::path mResDir;
|
||||||
|
Fallback::Map mFallbackMap;
|
||||||
|
|
||||||
|
bool mFsStrict;
|
||||||
|
Files::PathContainer mDataPaths;
|
||||||
|
std::vector<std::string> mArchives;
|
||||||
|
|
||||||
DocumentManager (const DocumentManager&);
|
DocumentManager (const DocumentManager&);
|
||||||
DocumentManager& operator= (const DocumentManager&);
|
DocumentManager& operator= (const DocumentManager&);
|
||||||
|
@ -74,15 +78,11 @@ namespace CSMDoc
|
||||||
|
|
||||||
void setBlacklistedScripts (const std::vector<std::string>& scriptIds);
|
void setBlacklistedScripts (const std::vector<std::string>& scriptIds);
|
||||||
|
|
||||||
void setVFS(VFS::Manager* vfs);
|
/// Sets the file data that gets passed to newly created documents.
|
||||||
|
void setFileData(bool strict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives);
|
||||||
|
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
boost::filesystem::path mResDir;
|
|
||||||
Fallback::Map mFallbackMap;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void documentLoaded (Document *document);
|
void documentLoaded (Document *document);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
#include <components/vfs/manager.hpp>
|
#include <components/vfs/manager.hpp>
|
||||||
|
#include <components/vfs/registerarchives.hpp>
|
||||||
|
|
||||||
#include "idtable.hpp"
|
#include "idtable.hpp"
|
||||||
#include "idtree.hpp"
|
#include "idtree.hpp"
|
||||||
|
@ -62,11 +63,18 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::Data::Data (ToUTF8::FromType encoding, VFS::Manager* vfs, ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir)
|
CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,
|
||||||
|
const std::vector<std::string>& archives, const Fallback::Map* fallback, const boost::filesystem::path& resDir)
|
||||||
: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells),
|
: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells),
|
||||||
mVFS(vfs), mResourcesManager (resourcesManager), mFallbackMap(fallback),
|
mFallbackMap(fallback), mReader (0), mDialogue (0), mReaderIndex(1),
|
||||||
mReader (0), mDialogue (0), mReaderIndex(1), mResourceSystem(new Resource::ResourceSystem(resourcesManager.getVFS()))
|
mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives)
|
||||||
{
|
{
|
||||||
|
mVFS.reset(new VFS::Manager(mFsStrict));
|
||||||
|
VFS::registerArchives(mVFS.get(), Files::Collections(mDataPaths, !mFsStrict), mArchives, true);
|
||||||
|
|
||||||
|
mResourcesManager.setVFS(mVFS.get());
|
||||||
|
mResourceSystem.reset(new Resource::ResourceSystem(mVFS.get()));
|
||||||
|
|
||||||
mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string());
|
mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string());
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -1218,7 +1226,8 @@ std::vector<std::string> CSMWorld::Data::getIds (bool listDeleted) const
|
||||||
|
|
||||||
void CSMWorld::Data::assetsChanged()
|
void CSMWorld::Data::assetsChanged()
|
||||||
{
|
{
|
||||||
mVFS->rebuildIndex();
|
mVFS.get()->reset();
|
||||||
|
VFS::registerArchives(mVFS.get(), Files::Collections(mDataPaths, !mFsStrict), mArchives, true);
|
||||||
|
|
||||||
const UniversalId assetTableIds[] = {
|
const UniversalId assetTableIds[] = {
|
||||||
UniversalId::Type_Meshes,
|
UniversalId::Type_Meshes,
|
||||||
|
@ -1265,7 +1274,7 @@ void CSMWorld::Data::rowsChanged (const QModelIndex& parent, int start, int end)
|
||||||
|
|
||||||
const VFS::Manager* CSMWorld::Data::getVFS() const
|
const VFS::Manager* CSMWorld::Data::getVFS() const
|
||||||
{
|
{
|
||||||
return mVFS;
|
return mVFS.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Fallback::Map* CSMWorld::Data::getFallbackMap() const
|
const Fallback::Map* CSMWorld::Data::getFallbackMap() const
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <components/resource/resourcesystem.hpp>
|
#include <components/resource/resourcesystem.hpp>
|
||||||
|
|
||||||
|
#include <components/files/multidircollection.hpp>
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "../doc/stage.hpp"
|
#include "../doc/stage.hpp"
|
||||||
|
@ -46,6 +47,7 @@
|
||||||
#include "infocollection.hpp"
|
#include "infocollection.hpp"
|
||||||
#include "nestedinfocollection.hpp"
|
#include "nestedinfocollection.hpp"
|
||||||
#include "pathgrid.hpp"
|
#include "pathgrid.hpp"
|
||||||
|
#include "resourcesmanager.hpp"
|
||||||
#include "metadata.hpp"
|
#include "metadata.hpp"
|
||||||
#ifndef Q_MOC_RUN
|
#ifndef Q_MOC_RUN
|
||||||
#include "subcellcollection.hpp"
|
#include "subcellcollection.hpp"
|
||||||
|
@ -108,8 +110,6 @@ namespace CSMWorld
|
||||||
RefCollection mRefs;
|
RefCollection mRefs;
|
||||||
IdCollection<ESM::Filter> mFilters;
|
IdCollection<ESM::Filter> mFilters;
|
||||||
Collection<MetaData> mMetaData;
|
Collection<MetaData> mMetaData;
|
||||||
VFS::Manager* mVFS;
|
|
||||||
ResourcesManager& mResourcesManager;
|
|
||||||
const Fallback::Map* mFallbackMap;
|
const Fallback::Map* mFallbackMap;
|
||||||
std::vector<QAbstractItemModel *> mModels;
|
std::vector<QAbstractItemModel *> mModels;
|
||||||
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
|
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
|
||||||
|
@ -120,6 +120,11 @@ namespace CSMWorld
|
||||||
std::map<std::string, std::map<ESM::RefNum, std::string> > mRefLoadCache;
|
std::map<std::string, std::map<ESM::RefNum, std::string> > mRefLoadCache;
|
||||||
int mReaderIndex;
|
int mReaderIndex;
|
||||||
|
|
||||||
|
bool mFsStrict;
|
||||||
|
Files::PathContainer mDataPaths;
|
||||||
|
std::vector<std::string> mArchives;
|
||||||
|
std::unique_ptr<VFS::Manager> mVFS;
|
||||||
|
ResourcesManager mResourcesManager;
|
||||||
std::shared_ptr<Resource::ResourceSystem> mResourceSystem;
|
std::shared_ptr<Resource::ResourceSystem> mResourceSystem;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<ESM::ESMReader> > mReaders;
|
std::vector<std::shared_ptr<ESM::ESMReader> > mReaders;
|
||||||
|
@ -141,7 +146,9 @@ namespace CSMWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Data (ToUTF8::FromType encoding, VFS::Manager* vfs, ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir);
|
Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,
|
||||||
|
const std::vector<std::string>& archives, const Fallback::Map* fallback,
|
||||||
|
const boost::filesystem::path& resDir);
|
||||||
|
|
||||||
virtual ~Data();
|
virtual ~Data();
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,6 @@ namespace VFS
|
||||||
public:
|
public:
|
||||||
virtual ~Archive() {}
|
virtual ~Archive() {}
|
||||||
|
|
||||||
/// Clears cached data.
|
|
||||||
virtual void reset() = 0;
|
|
||||||
|
|
||||||
/// List all resources contained in this archive, and run the resource names through the given normalize function.
|
/// 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;
|
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char)) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,12 +10,6 @@ BsaArchive::BsaArchive(const std::string &filename)
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BsaArchive::reset()
|
|
||||||
{
|
|
||||||
mResources.clear();
|
|
||||||
load();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BsaArchive::listResources(std::map<std::string, File *> &out, char (*normalize_function)(char))
|
void BsaArchive::listResources(std::map<std::string, File *> &out, char (*normalize_function)(char))
|
||||||
{
|
{
|
||||||
for (std::vector<BsaArchiveFile>::iterator it = mResources.begin(); it != mResources.end(); ++it)
|
for (std::vector<BsaArchiveFile>::iterator it = mResources.begin(); it != mResources.end(); ++it)
|
||||||
|
|
|
@ -24,8 +24,6 @@ namespace VFS
|
||||||
public:
|
public:
|
||||||
BsaArchive(const std::string& filename);
|
BsaArchive(const std::string& filename);
|
||||||
|
|
||||||
virtual void reset();
|
|
||||||
|
|
||||||
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));
|
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -12,12 +12,6 @@ namespace VFS
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSystemArchive::reset()
|
|
||||||
{
|
|
||||||
mIndex.clear();
|
|
||||||
mBuiltIndex = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileSystemArchive::listResources(std::map<std::string, File *> &out, char (*normalize_function)(char))
|
void FileSystemArchive::listResources(std::map<std::string, File *> &out, char (*normalize_function)(char))
|
||||||
{
|
{
|
||||||
if (!mBuiltIndex)
|
if (!mBuiltIndex)
|
||||||
|
|
|
@ -23,8 +23,6 @@ namespace VFS
|
||||||
public:
|
public:
|
||||||
FileSystemArchive(const std::string& path);
|
FileSystemArchive(const std::string& path);
|
||||||
|
|
||||||
virtual void reset();
|
|
||||||
|
|
||||||
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));
|
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,12 @@ namespace VFS
|
||||||
|
|
||||||
Manager::~Manager()
|
Manager::~Manager()
|
||||||
{
|
{
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Manager::reset()
|
||||||
|
{
|
||||||
|
mIndex.clear();
|
||||||
for (std::vector<Archive*>::iterator it = mArchives.begin(); it != mArchives.end(); ++it)
|
for (std::vector<Archive*>::iterator it = mArchives.begin(); it != mArchives.end(); ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
mArchives.clear();
|
mArchives.clear();
|
||||||
|
@ -57,14 +63,6 @@ namespace VFS
|
||||||
(*it)->listResources(mIndex, mStrict ? &strict_normalize_char : &nonstrict_normalize_char);
|
(*it)->listResources(mIndex, mStrict ? &strict_normalize_char : &nonstrict_normalize_char);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::rebuildIndex()
|
|
||||||
{
|
|
||||||
for (std::vector<Archive*>::const_iterator it = mArchives.begin(); it != mArchives.end(); ++it)
|
|
||||||
(*it)->reset();
|
|
||||||
|
|
||||||
buildIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
Files::IStreamPtr Manager::get(const std::string &name) const
|
Files::IStreamPtr Manager::get(const std::string &name) const
|
||||||
{
|
{
|
||||||
std::string normalized = name;
|
std::string normalized = name;
|
||||||
|
|
|
@ -26,6 +26,9 @@ namespace VFS
|
||||||
|
|
||||||
~Manager();
|
~Manager();
|
||||||
|
|
||||||
|
// Empty the file index and unregister archives.
|
||||||
|
void reset();
|
||||||
|
|
||||||
/// Register the given archive. All files contained in it will be added to the index on the next buildIndex() call.
|
/// Register the given archive. All files contained in it will be added to the index on the next buildIndex() call.
|
||||||
/// @note Takes ownership of the given pointer.
|
/// @note Takes ownership of the given pointer.
|
||||||
void addArchive(Archive* archive);
|
void addArchive(Archive* archive);
|
||||||
|
@ -33,9 +36,6 @@ namespace VFS
|
||||||
/// Build the file index. Should be called when all archives have been registered.
|
/// Build the file index. Should be called when all archives have been registered.
|
||||||
void buildIndex();
|
void buildIndex();
|
||||||
|
|
||||||
/// Rebuild the file index. New/deleted files (actual files, not bsa's) will be reflected.
|
|
||||||
void rebuildIndex();
|
|
||||||
|
|
||||||
/// Does a file with this name exist?
|
/// Does a file with this name exist?
|
||||||
/// @note May be called from any thread once the index has been built.
|
/// @note May be called from any thread once the index has been built.
|
||||||
bool exists(const std::string& name) const;
|
bool exists(const std::string& name) const;
|
||||||
|
|
Loading…
Reference in a new issue