mirror of https://github.com/OpenMW/openmw.git
Merge branch 'vfs_normalized_path' into 'master'
Add type for normalized VFS path and use for VFS::Manager file map key See merge request OpenMW/openmw!3781ini_importer_tests
commit
ec6ac8058b
@ -0,0 +1,21 @@
|
||||
#ifndef OPENMW_COMPONENTS_VFS_FILE_H
|
||||
#define OPENMW_COMPONENTS_VFS_FILE_H
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include <components/files/istreamptr.hpp>
|
||||
|
||||
namespace VFS
|
||||
{
|
||||
class File
|
||||
{
|
||||
public:
|
||||
virtual ~File() = default;
|
||||
|
||||
virtual Files::IStreamPtr open() = 0;
|
||||
|
||||
virtual std::filesystem::path getPath() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,19 @@
|
||||
#ifndef OPENMW_COMPONENTS_VFS_FILEMAP_H
|
||||
#define OPENMW_COMPONENTS_VFS_FILEMAP_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace VFS
|
||||
{
|
||||
class File;
|
||||
|
||||
namespace Path
|
||||
{
|
||||
class Normalized;
|
||||
}
|
||||
|
||||
using FileMap = std::map<Path::Normalized, File*, std::less<>>;
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,54 @@
|
||||
#ifndef OPENMW_COMPONENTS_VFS_RECURSIVEDIRECTORYITERATOR_H
|
||||
#define OPENMW_COMPONENTS_VFS_RECURSIVEDIRECTORYITERATOR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "filemap.hpp"
|
||||
#include "pathutil.hpp"
|
||||
|
||||
namespace VFS
|
||||
{
|
||||
class RecursiveDirectoryIterator
|
||||
{
|
||||
public:
|
||||
RecursiveDirectoryIterator(FileMap::const_iterator it)
|
||||
: mIt(it)
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& operator*() const { return mIt->first.value(); }
|
||||
|
||||
const std::string* operator->() const { return &mIt->first.value(); }
|
||||
|
||||
RecursiveDirectoryIterator& operator++()
|
||||
{
|
||||
++mIt;
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend bool operator==(const RecursiveDirectoryIterator& lhs, const RecursiveDirectoryIterator& rhs) = default;
|
||||
|
||||
private:
|
||||
FileMap::const_iterator mIt;
|
||||
};
|
||||
|
||||
class RecursiveDirectoryRange
|
||||
{
|
||||
public:
|
||||
RecursiveDirectoryRange(RecursiveDirectoryIterator first, RecursiveDirectoryIterator last)
|
||||
: mBegin(first)
|
||||
, mEnd(last)
|
||||
{
|
||||
}
|
||||
|
||||
RecursiveDirectoryIterator begin() const { return mBegin; }
|
||||
|
||||
RecursiveDirectoryIterator end() const { return mEnd; }
|
||||
|
||||
private:
|
||||
RecursiveDirectoryIterator mBegin;
|
||||
RecursiveDirectoryIterator mEnd;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue