55 if (fread(p_buffer, 1, p_size,
m_file) != p_size) {
67 if (fwrite(p_buffer, 1, p_size,
m_file) != p_size) {
83 p_position = position;
93 if (fseek(
m_file, p_position, SEEK_SET) != 0) {
117 if ((p_mode &
c_text) != 0) {
124 if (!(
m_file = fopen(p_name, mode))) {
Implementation of LegoStorage for file-backed storage using stdio FILE*.
LegoResult Read(void *p_buffer, LegoU32 p_size) override
Reads bytes from file at current position.
FILE * m_file
C runtime file pointer backing storage.
~LegoFile() override
Destructor.
LegoFile()
Default constructor initializes with NULL file pointer.
LegoResult GetPosition(LegoU32 &p_position) override
Gets the current file pointer position relative to beginning.
LegoResult Open(const char *p_name, LegoU32 p_mode)
Opens a file with given name and mode, closing existing file if needed.
LegoResult Write(const void *p_buffer, LegoU32 p_size) override
Writes bytes to file at current position.
LegoResult SetPosition(LegoU32 p_position) override
Sets the current file pointer position.
Implementation of LegoStorage for memory-backed buffers.
LegoU8 * m_buffer
Pointer to target memory buffer for reading/writing.
LegoResult Read(void *p_buffer, LegoU32 p_size) override
Reads bytes from memory buffer at current position.
LegoU32 m_position
Current read/write offset in buffer.
LegoMemory(void *p_buffer)
Constructor setting internal buffer pointer and resets position.
LegoResult Write(const void *p_buffer, LegoU32 p_size) override
Writes bytes to memory buffer at current position.
Abstract base class providing an interface for file-like storage with binary and text read/write oper...
LegoU8 m_mode
File open/access mode.
@ c_read
Open for read operations. [AI].
@ c_write
Open for write operations. [AI].
@ c_text
Open in text mode, otherwise binary. [AI].
#define DECOMP_SIZE_ASSERT(T, S)
#define NULL
[AI] Null pointer value (C/C++ semantics).
unsigned long LegoU32
[AI] Unsigned 32-bit integer type for cross-platform compatibility.
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
unsigned char LegoU8
[AI] Unsigned 8-bit integer type used throughout LEGO Island.
LegoS32 LegoResult
[AI] Function result type (return code): typically SUCCESS (0) or FAILURE (-1).
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.