2015-02-17 11:26:28 +00:00
|
|
|
#ifndef OPENMW_CONSTRAINEDFILESTREAM_H
|
|
|
|
#define OPENMW_CONSTRAINEDFILESTREAM_H
|
|
|
|
|
|
|
|
#include <istream>
|
2017-05-05 19:21:11 +00:00
|
|
|
#include <memory>
|
2015-02-17 15:19:21 +00:00
|
|
|
|
2015-02-17 11:26:28 +00:00
|
|
|
namespace Files
|
|
|
|
{
|
|
|
|
|
|
|
|
/// A file stream constrained to a specific region in the file, specified by the 'start' and 'length' parameters.
|
|
|
|
class ConstrainedFileStream : public std::istream
|
|
|
|
{
|
|
|
|
public:
|
2018-09-08 19:04:42 +00:00
|
|
|
ConstrainedFileStream(std::unique_ptr<std::streambuf> buf);
|
|
|
|
virtual ~ConstrainedFileStream() {};
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<std::streambuf> mBuf;
|
2015-02-17 11:26:28 +00:00
|
|
|
};
|
|
|
|
|
2017-05-05 17:26:09 +00:00
|
|
|
typedef std::shared_ptr<std::istream> IStreamPtr;
|
2015-02-17 15:19:21 +00:00
|
|
|
|
2015-02-20 16:57:18 +00:00
|
|
|
IStreamPtr openConstrainedFileStream(const char *filename, size_t start=0, size_t length=0xFFFFFFFF);
|
2015-02-17 15:19:21 +00:00
|
|
|
|
2015-02-17 11:26:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|