22 #include "precompiled.h"
50 strncpy(header.
magic, magic, 4);
72 LOGERROR(L
"Failed to write file '%ls' with status '%lld'", filename.
string().c_str(), (
long long)st);
86 PackRaw(&value_le32,
sizeof(value_le32));
91 const size_t length = str.length();
101 : m_bufSize(0), m_unpackPos(0), m_version(0)
157 memcpy(rawData, src, rawDataSize);
165 UnpackRaw(&value_le32,
sizeof(value_le32));
166 return (
size_t)
to_le32(value_le32);
void UnpackRaw(void *rawData, size_t rawDataSize)
unpack given number of bytes from the input into the given array.
u32 read_le32(const void *p)
void Append(const void *data, size_t size)
void PackRaw(const void *rawData, size_t rawDataSize)
pack given number of bytes onto the end of the data stream
WriteBuffer m_writeBuffer
the output data stream built during pack operations.
void Overwrite(const void *data, size_t size, size_t offset)
shared_ptr< u8 > Data() const
const String & string() const
void Read(const VfsPath &filename, const char magic[4])
open and read in given file, check magic bits against those given; throw variety of exceptions if ope...
CFilePacker(u32 version, const char magic[4])
adds version and signature (i.e.
size_t UnpackSize()
use UnpackRaw to retrieve 32-bits; returns their value as size_t after converting from little endian ...
void UnpackString(CStr8 &result)
unpack a string from the raw data stream.
i64 Status
Error handling system.
bool VfsFileExists(const VfsPath &pathname)
void Write(const VfsPath &filename)
write out to file all packed data added so far.
u32 m_version
current unpack position in stream
void PackSize(size_t value)
convenience: convert a number (almost always a size type) to little-endian u32 and pack that...
#define cassert(expr)
Compile-time assertion.
void PackString(const CStr &str)
pack a string onto the end of the data stream (encoded as a 32-bit length followed by the characters)...
void write_le32(void *p, u32 x)