mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 12:06:41 +00:00
Move Files::IStreamPtr alias to a separate header
To avoid transitive include of Windows.h all over the engine.
This commit is contained in:
parent
bf17dc55e5
commit
6c8ed4d19c
17 changed files with 52 additions and 24 deletions
|
@ -24,7 +24,7 @@ extern "C"
|
||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <components/files/constrainedfilestream.hpp>
|
#include <components/files/istreamptr.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#include "bsa_file.hpp"
|
#include "bsa_file.hpp"
|
||||||
|
|
||||||
|
#include <components/files/constrainedfilestream.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -256,6 +258,11 @@ void Bsa::BSAFile::close()
|
||||||
mIsLoaded = false;
|
mIsLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Files::IStreamPtr Bsa::BSAFile::getFile(const FileStruct *file)
|
||||||
|
{
|
||||||
|
return Files::openConstrainedFileStream(mFilename, file->offset, file->fileSize);
|
||||||
|
}
|
||||||
|
|
||||||
void Bsa::BSAFile::addFile(const std::string& filename, std::istream& file)
|
void Bsa::BSAFile::addFile(const std::string& filename, std::istream& file)
|
||||||
{
|
{
|
||||||
if (!mIsLoaded)
|
if (!mIsLoaded)
|
||||||
|
|
|
@ -28,8 +28,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <components/files/constrainedfilestream.hpp>
|
#include <components/files/istreamptr.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace Bsa
|
namespace Bsa
|
||||||
{
|
{
|
||||||
|
@ -123,10 +122,7 @@ public:
|
||||||
/** Open a file contained in the archive.
|
/** Open a file contained in the archive.
|
||||||
* @note Thread safe.
|
* @note Thread safe.
|
||||||
*/
|
*/
|
||||||
Files::IStreamPtr getFile(const FileStruct *file)
|
Files::IStreamPtr getFile(const FileStruct *file);
|
||||||
{
|
|
||||||
return Files::openConstrainedFileStream(mFilename, file->offset, file->fileSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void addFile(const std::string& filename, std::istream& file);
|
void addFile(const std::string& filename, std::istream& file);
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include <boost/iostreams/device/array.hpp>
|
#include <boost/iostreams/device/array.hpp>
|
||||||
#include <components/bsa/memorystream.hpp>
|
#include <components/bsa/memorystream.hpp>
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
|
#include <components/files/constrainedfilestream.hpp>
|
||||||
|
|
||||||
namespace Bsa
|
namespace Bsa
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <components/files/constrainedfilestream.hpp>
|
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "common.hpp" // MasterData
|
#include "common.hpp" // MasterData
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
|
|
||||||
#include <components/bsa/memorystream.hpp>
|
#include <components/bsa/memorystream.hpp>
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
|
#include <components/files/constrainedfilestream.hpp>
|
||||||
|
|
||||||
#include "formid.hpp"
|
#include "formid.hpp"
|
||||||
|
|
||||||
|
@ -182,6 +183,16 @@ void Reader::open(Files::IStreamPtr&& stream, const std::string &filename)
|
||||||
throw std::runtime_error("Unknown file format"); // can't yet use fail() as mCtx is not setup
|
throw std::runtime_error("Unknown file format"); // can't yet use fail() as mCtx is not setup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Reader::openRaw(const std::string& filename)
|
||||||
|
{
|
||||||
|
openRaw(Files::openConstrainedFileStream(filename), filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reader::open(const std::string& filename)
|
||||||
|
{
|
||||||
|
open(Files::openConstrainedFileStream(filename), filename);
|
||||||
|
}
|
||||||
|
|
||||||
void Reader::setRecHeaderSize(const std::size_t size)
|
void Reader::setRecHeaderSize(const std::size_t size)
|
||||||
{
|
{
|
||||||
mCtx.recHeaderSize = size;
|
mCtx.recHeaderSize = size;
|
||||||
|
|
|
@ -26,11 +26,14 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "loadtes4.hpp"
|
#include "loadtes4.hpp"
|
||||||
#include "../esm/reader.hpp"
|
#include "../esm/reader.hpp"
|
||||||
|
|
||||||
|
#include <components/files/istreamptr.hpp>
|
||||||
|
|
||||||
namespace ESM4 {
|
namespace ESM4 {
|
||||||
// bytes read from group, updated by
|
// bytes read from group, updated by
|
||||||
// getRecordHeader() in advance
|
// getRecordHeader() in advance
|
||||||
|
@ -129,15 +132,9 @@ namespace ESM4 {
|
||||||
~Reader();
|
~Reader();
|
||||||
|
|
||||||
// FIXME: should be private but ESMTool uses it
|
// FIXME: should be private but ESMTool uses it
|
||||||
void openRaw(const std::string& filename)
|
void openRaw(const std::string& filename);
|
||||||
{
|
|
||||||
openRaw(Files::openConstrainedFileStream(filename), filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
void open(const std::string& filename)
|
void open(const std::string& filename);
|
||||||
{
|
|
||||||
open(Files::openConstrainedFileStream(filename), filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
void close() final;
|
void close() final;
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
|
|
||||||
#include "constrainedfilestreambuf.hpp"
|
#include "constrainedfilestreambuf.hpp"
|
||||||
#include "streamwithbuffer.hpp"
|
#include "streamwithbuffer.hpp"
|
||||||
|
#include "istreamptr.hpp"
|
||||||
|
|
||||||
#include <iosfwd>
|
|
||||||
#include <memory>
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -15,8 +14,6 @@ namespace Files
|
||||||
/// A file stream constrained to a specific region in the file, specified by the 'start' and 'length' parameters.
|
/// A file stream constrained to a specific region in the file, specified by the 'start' and 'length' parameters.
|
||||||
using ConstrainedFileStream = StreamWithBuffer<ConstrainedFileStreamBuf>;
|
using ConstrainedFileStream = StreamWithBuffer<ConstrainedFileStreamBuf>;
|
||||||
|
|
||||||
typedef std::unique_ptr<std::istream> IStreamPtr;
|
|
||||||
|
|
||||||
IStreamPtr openConstrainedFileStream(const std::string& filename, std::size_t start = 0,
|
IStreamPtr openConstrainedFileStream(const std::string& filename, std::size_t start = 0,
|
||||||
std::size_t length = std::numeric_limits<std::size_t>::max());
|
std::size_t length = std::numeric_limits<std::size_t>::max());
|
||||||
|
|
||||||
|
|
12
components/files/istreamptr.hpp
Normal file
12
components/files/istreamptr.hpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef OPENMW_COMPONENTS_FILES_ISTREAMPTR_H
|
||||||
|
#define OPENMW_COMPONENTS_FILES_ISTREAMPTR_H
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace Files
|
||||||
|
{
|
||||||
|
using IStreamPtr = std::unique_ptr<std::istream>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -6,9 +6,10 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/files/constrainedfilestream.hpp>
|
#include <components/files/istreamptr.hpp>
|
||||||
|
|
||||||
#include "record.hpp"
|
#include "record.hpp"
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
#include <components/files/constrainedfilestream.hpp>
|
#include <components/files/istreamptr.hpp>
|
||||||
#include <components/misc/endianness.hpp>
|
#include <components/misc/endianness.hpp>
|
||||||
|
|
||||||
#include <osg/Vec3f>
|
#include <osg/Vec3f>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <components/files/constrainedfilestream.hpp>
|
#include <components/files/istreamptr.hpp>
|
||||||
|
|
||||||
namespace VFS
|
namespace VFS
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
namespace VFS
|
namespace VFS
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
#include <components/files/constrainedfilestream.hpp>
|
||||||
|
|
||||||
namespace VFS
|
namespace VFS
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "archive.hpp"
|
#include "archive.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace VFS
|
namespace VFS
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "manager.hpp"
|
#include "manager.hpp"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#ifndef OPENMW_COMPONENTS_RESOURCEMANAGER_H
|
#ifndef OPENMW_COMPONENTS_RESOURCEMANAGER_H
|
||||||
#define OPENMW_COMPONENTS_RESOURCEMANAGER_H
|
#define OPENMW_COMPONENTS_RESOURCEMANAGER_H
|
||||||
|
|
||||||
#include <components/files/constrainedfilestream.hpp>
|
#include <components/files/istreamptr.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace VFS
|
namespace VFS
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue