Worldstone
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
WorldStone::MpqFileStream Class Reference

A file from a MpqArchive. More...

#include <MpqArchive.h>

Inheritance diagram for WorldStone::MpqFileStream:
WorldStone::IStream WorldStone::IOBase

Public Member Functions

 MpqFileStream (MpqArchive &archive, const Path &filename)
 
bool open (MpqArchive &archive, const Path &filename)
 
bool is_open () const
 
bool close ()
 
size_t read (void *buffer, size_t size) override
 Read data from the stream. More...
 
long tell () override
 Return the current position of the stream pointer. More...
 
long size () override
 Compute the size of the file. More...
 
bool seek (long offset, seekdir origin) override
 
- Public Member Functions inherited from WorldStone::IStream
bool eof () const
 True if the end of the stream was reached during the last read operation.
 
template<typename T >
bool readRaw (T &out)
 
virtual int getc ()
 Read one byte from the stream. More...
 
- Public Member Functions inherited from WorldStone::IOBase
 operator bool () const
 
bool operator! () const
 
bool good () const
 
bool eof () const
 
bool fail () const
 
bool bad () const
 

Additional Inherited Members

- Public Types inherited from WorldStone::IStream
enum  seekdir { beg, cur, end }
 
- Public Types inherited from WorldStone::IOBase
using Path = std::string
 
using iostate = int
 
- Protected Member Functions inherited from WorldStone::IOBase
void setstate (iostate state)
 
- Protected Attributes inherited from WorldStone::IOBase
iostate _state = goodbit
 
- Static Protected Attributes inherited from WorldStone::IOBase
static constexpr iostate goodbit = 0x0
 
static constexpr iostate eofbit = 0x1
 
static constexpr iostate failbit = 0x2
 
static constexpr iostate badbit = 0x4
 

Detailed Description

A file from a MpqArchive.

Definition at line 47 of file MpqArchive.h.

Member Function Documentation

size_t WorldStone::MpqFileStream::read ( void *  buffer,
size_t  size 
)
overridevirtual

Read data from the stream.

Parameters
bufferPointer to a block of memory to fill. Must be at least 'size' bytes large.
sizeNumber of bytes to copy
Returns
The number of bytes successfully read. If less than 'size', EOF was reached or an error occured.

Implements WorldStone::IStream.

Definition at line 98 of file MpqArchive.cpp.

bool WorldStone::MpqFileStream::seek ( long  offset,
IStream::seekdir  origin 
)
overridevirtual
Warning
offset value must fit in 32bits

Implements WorldStone::IStream.

Definition at line 124 of file MpqArchive.cpp.

long WorldStone::MpqFileStream::size ( )
overridevirtual

Compute the size of the file.

Returns
the size of the file, or a negative value on error

Implements WorldStone::IStream.

Definition at line 131 of file MpqArchive.cpp.

long WorldStone::MpqFileStream::tell ( )
overridevirtual

Return the current position of the stream pointer.

Returns
The offset in bytes to the currently pointed position. A negative value on failure.
Note
The seek method can be used to restore a position.

Implements WorldStone::IStream.

Definition at line 113 of file MpqArchive.cpp.


The documentation for this class was generated from the following files: