Move Files::IStreamPtr alias to a separate header

To avoid transitive include of Windows.h all over the engine.
LTO-timing^2
elsid 2 years ago
parent bf17dc55e5
commit 6c8ed4d19c
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -24,7 +24,7 @@ extern "C"
#pragma warning (pop)
#endif
#include <components/files/constrainedfilestream.hpp>
#include <components/files/istreamptr.hpp>
#include <string>

@ -23,6 +23,8 @@
#include "bsa_file.hpp"
#include <components/files/constrainedfilestream.hpp>
#include <algorithm>
#include <cassert>
#include <cstring>
@ -256,6 +258,11 @@ void Bsa::BSAFile::close()
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)
{
if (!mIsLoaded)

@ -28,8 +28,7 @@
#include <string>
#include <vector>
#include <components/files/constrainedfilestream.hpp>
#include <components/files/istreamptr.hpp>
namespace Bsa
{
@ -123,10 +122,7 @@ public:
/** Open a file contained in the archive.
* @note Thread safe.
*/
Files::IStreamPtr getFile(const FileStruct *file)
{
return Files::openConstrainedFileStream(mFilename, file->offset, file->fileSize);
}
Files::IStreamPtr getFile(const FileStruct *file);
void addFile(const std::string& filename, std::istream& file);

@ -47,6 +47,7 @@
#include <boost/iostreams/device/array.hpp>
#include <components/bsa/memorystream.hpp>
#include <components/misc/stringops.hpp>
#include <components/files/constrainedfilestream.hpp>
namespace Bsa
{

@ -3,7 +3,6 @@
#include <vector>
#include <components/files/constrainedfilestream.hpp>
#include <components/to_utf8/to_utf8.hpp>
#include "common.hpp" // MasterData

@ -49,6 +49,7 @@
#include <components/bsa/memorystream.hpp>
#include <components/misc/stringops.hpp>
#include <components/files/constrainedfilestream.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
}
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)
{
mCtx.recHeaderSize = size;

@ -26,11 +26,14 @@
#include <map>
#include <cstddef>
#include <memory>
#include <istream>
#include "common.hpp"
#include "loadtes4.hpp"
#include "../esm/reader.hpp"
#include <components/files/istreamptr.hpp>
namespace ESM4 {
// bytes read from group, updated by
// getRecordHeader() in advance
@ -129,15 +132,9 @@ namespace ESM4 {
~Reader();
// FIXME: should be private but ESMTool uses it
void openRaw(const std::string& filename)
{
openRaw(Files::openConstrainedFileStream(filename), filename);
}
void openRaw(const std::string& filename);
void open(const std::string& filename)
{
open(Files::openConstrainedFileStream(filename), filename);
}
void open(const std::string& filename);
void close() final;

@ -3,9 +3,8 @@
#include "constrainedfilestreambuf.hpp"
#include "streamwithbuffer.hpp"
#include "istreamptr.hpp"
#include <iosfwd>
#include <memory>
#include <limits>
#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.
using ConstrainedFileStream = StreamWithBuffer<ConstrainedFileStreamBuf>;
typedef std::unique_ptr<std::istream> IStreamPtr;
IStreamPtr openConstrainedFileStream(const std::string& filename, std::size_t start = 0,
std::size_t length = std::numeric_limits<std::size_t>::max());

@ -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 <vector>
#include <atomic>
#include <limits>
#include <components/debug/debuglog.hpp>
#include <components/files/constrainedfilestream.hpp>
#include <components/files/istreamptr.hpp>
#include "record.hpp"

@ -9,8 +9,9 @@
#include <vector>
#include <typeinfo>
#include <type_traits>
#include <istream>
#include <components/files/constrainedfilestream.hpp>
#include <components/files/istreamptr.hpp>
#include <components/misc/endianness.hpp>
#include <osg/Vec3f>

@ -3,7 +3,7 @@
#include <map>
#include <components/files/constrainedfilestream.hpp>
#include <components/files/istreamptr.hpp>
namespace VFS
{

@ -2,6 +2,7 @@
#include <memory>
#include <algorithm>
#include <istream>
namespace VFS
{

@ -5,6 +5,7 @@
#include <filesystem>
#include <components/debug/debuglog.hpp>
#include <components/files/constrainedfilestream.hpp>
namespace VFS
{

@ -3,6 +3,8 @@
#include "archive.hpp"
#include <string>
namespace VFS
{

@ -1,6 +1,7 @@
#include "manager.hpp"
#include <stdexcept>
#include <istream>
#include <components/misc/stringops.hpp>

@ -1,11 +1,12 @@
#ifndef OPENMW_COMPONENTS_RESOURCEMANAGER_H
#define OPENMW_COMPONENTS_RESOURCEMANAGER_H
#include <components/files/constrainedfilestream.hpp>
#include <components/files/istreamptr.hpp>
#include <vector>
#include <map>
#include <memory>
#include <string>
namespace VFS
{

Loading…
Cancel
Save