WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
GameFile Class Referenceabstract

Abstract base class representing a file within the game data archive. More...

#include <GameFile.h>

Inheritance diagram for GameFile:
[legend]
Collaboration diagram for GameFile:
[legend]

Classes

struct  Chunk
 

Public Member Functions

 GameFile (std::string path, int id=-1)
 
virtual ~GameFile ()=default
 
virtual size_t read (void *dest, size_t bytes)
 Read bytes from the file into dest.
 
size_t getSize ()
 Total size of the file in bytes.
 
size_t getPos ()
 Current read position.
 
unsigned char * getBuffer () const
 Pointer to the start of the internal buffer.
 
unsigned char * getPointer ()
 Pointer to the current read position within the buffer.
 
bool isEof ()
 True if the read pointer has reached the end of the file.
 
virtual void seek (size_t offset)
 Seek to an absolute byte offset.
 
void seekRelative (size_t offset)
 Advance the read pointer by offset bytes.
 
bool open (bool useMemoryBuffer=true)
 Open the file, optionally loading into a memory buffer.
 
bool close ()
 Close the file and release the internal buffer.
 
void setFullName (const std::string &name)
 
const std::string & fullname () const
 
int fileDataId ()
 
void allocate (unsigned long long size)
 Allocate (or reallocate) the internal buffer to the given size.
 
bool setChunk (std::string chunkName, bool resetToStart=true)
 Switch the active read window to the named chunk.
 
bool isChunked ()
 True if the file has been parsed into named chunks.
 
virtual void dumpStructure ()
 
- Public Member Functions inherited from Component
 Component ()
 
virtual ~Component ()
 
virtual bool addChild (Component *)
 Add a child component to this node.
 
virtual bool removeChild (Component *)
 Remove a child component from this node.
 
virtual void removeAllChildren ()
 
virtual unsigned int nbChildren () const
 
virtual bool findChildComponent (Component *, bool)
 
virtual ComponentgetChild (unsigned int)
 
virtual const ComponentgetChild (unsigned int) const
 
void setParentComponent (Component *)
 Set the parent of this component.
 
virtual void onParentSet (Component *)
 Called after the parent has been set; override for custom logic.
 
const Componentparent () const
 Get the parent component (const).
 
Componentparent ()
 Get the parent component.
 
template<class DataType >
const DataType * firstParentOfType ()
 Walk up the parent chain and return the first ancestor of the given type.
 
void ref ()
 Increment the reference counter.
 
void unref ()
 Decrement the reference counter; deletes this when it reaches zero.
 
void setName (const std::string &name)
 
std::string name () const
 
virtual void onNameChanged ()
 
void print (int l_depth=0)
 
virtual void doPrint ()
 
void copy (const Component &component, bool)
 

Protected Member Functions

virtual bool openFile ()=0
 
virtual bool isAlreadyOpened ()=0
 
virtual bool getFileSize (unsigned long long &s)=0
 
virtual unsigned long readFile ()=0
 
virtual void doPostOpenOperation ()=0
 
virtual bool doPostCloseOperation ()=0
 

Protected Attributes

bool eof
 
unsigned char * buffer
 
unsigned long long pointer
 
unsigned long long size
 
std::string filepath
 
int m_fileDataId
 
std::vector< Chunkchunks
 
bool m_useMemoryBuffer
 

Private Member Functions

 GameFile (const GameFile &)=delete
 
GameFileoperator= (const GameFile &)=delete
 

Private Attributes

unsigned char * originalBuffer
 
std::string curChunk
 

Detailed Description

Abstract base class representing a file within the game data archive.

Provides a memory-buffered read interface with seek, chunk navigation, and subclass hooks for the actual I/O backend (CASC, hard-drive, etc.).

Definition at line 11 of file GameFile.h.

Constructor & Destructor Documentation

◆ GameFile() [1/2]

GameFile::GameFile ( std::string  path,
int  id = -1 
)
inline

Definition at line 14 of file GameFile.h.

◆ ~GameFile()

virtual GameFile::~GameFile ( )
virtualdefault

◆ GameFile() [2/2]

GameFile::GameFile ( const GameFile )
privatedelete

Member Function Documentation

◆ allocate()

void GameFile::allocate ( unsigned long long  size)

Allocate (or reallocate) the internal buffer to the given size.

Definition at line 84 of file GameFile.cpp.

Here is the caller graph for this function:

◆ close()

bool GameFile::close ( )

Close the file and release the internal buffer.

Definition at line 74 of file GameFile.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doPostCloseOperation()

virtual bool GameFile::doPostCloseOperation ( )
protectedpure virtual

Implemented in CASCFile, and HardDriveFile.

Here is the caller graph for this function:

◆ doPostOpenOperation()

virtual void GameFile::doPostOpenOperation ( )
protectedpure virtual

Implemented in CASCFile.

Here is the caller graph for this function:

◆ dumpStructure()

void GameFile::dumpStructure ( )
virtual

Reimplemented in CASCFile.

Definition at line 154 of file GameFile.cpp.

◆ fileDataId()

int GameFile::fileDataId ( )
inline

Definition at line 57 of file GameFile.h.

Here is the caller graph for this function:

◆ fullname()

const std::string & GameFile::fullname ( ) const
inline

Definition at line 56 of file GameFile.h.

Here is the caller graph for this function:

◆ getBuffer()

unsigned char * GameFile::getBuffer ( ) const

Pointer to the start of the internal buffer.

Definition at line 144 of file GameFile.cpp.

Here is the caller graph for this function:

◆ getFileSize()

virtual bool GameFile::getFileSize ( unsigned long long &  s)
protectedpure virtual

Implemented in CASCFile, and HardDriveFile.

Here is the caller graph for this function:

◆ getPointer()

unsigned char * GameFile::getPointer ( )

Pointer to the current read position within the buffer.

Definition at line 149 of file GameFile.cpp.

◆ getPos()

size_t GameFile::getPos ( )

Current read position.

Definition at line 139 of file GameFile.cpp.

Here is the caller graph for this function:

◆ getSize()

size_t GameFile::getSize ( )

Total size of the file in bytes.

Definition at line 134 of file GameFile.cpp.

Here is the caller graph for this function:

◆ isAlreadyOpened()

virtual bool GameFile::isAlreadyOpened ( )
protectedpure virtual

Implemented in CASCFile, and HardDriveFile.

Here is the caller graph for this function:

◆ isChunked()

bool GameFile::isChunked ( )
inline

True if the file has been parsed into named chunks.

Definition at line 69 of file GameFile.h.

Here is the caller graph for this function:

◆ isEof()

bool GameFile::isEof ( )

True if the read pointer has reached the end of the file.

Definition at line 24 of file GameFile.cpp.

Here is the caller graph for this function:

◆ open()

bool GameFile::open ( bool  useMemoryBuffer = true)

Open the file, optionally loading into a memory buffer.

Returns
true on success.

Definition at line 41 of file GameFile.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openFile()

virtual bool GameFile::openFile ( )
protectedpure virtual

Implemented in CASCFile, and HardDriveFile.

Here is the caller graph for this function:

◆ operator=()

GameFile & GameFile::operator= ( const GameFile )
privatedelete

◆ read()

size_t GameFile::read ( void *  dest,
size_t  bytes 
)
virtual

Read bytes from the file into dest.

Returns
Number of bytes actually read.

Reimplemented in CASCFile.

Definition at line 5 of file GameFile.cpp.

Here is the caller graph for this function:

◆ readFile()

virtual unsigned long GameFile::readFile ( )
protectedpure virtual

Implemented in CASCFile, and HardDriveFile.

Here is the caller graph for this function:

◆ seek()

void GameFile::seek ( size_t  offset)
virtual

Seek to an absolute byte offset.

Reimplemented in CASCFile.

Definition at line 29 of file GameFile.cpp.

Here is the caller graph for this function:

◆ seekRelative()

void GameFile::seekRelative ( size_t  offset)

Advance the read pointer by offset bytes.

Definition at line 35 of file GameFile.cpp.

Here is the caller graph for this function:

◆ setChunk()

bool GameFile::setChunk ( std::string  chunkName,
bool  resetToStart = true 
)

Switch the active read window to the named chunk.

Parameters
chunkNameFour-character chunk identifier.
resetToStartIf true, reset the read pointer to the chunk start.
Returns
true if the chunk was found.

Definition at line 100 of file GameFile.cpp.

Here is the caller graph for this function:

◆ setFullName()

void GameFile::setFullName ( const std::string &  name)
inline

Definition at line 55 of file GameFile.h.

Here is the call graph for this function:

Member Data Documentation

◆ buffer

unsigned char* GameFile::buffer
protected

Definition at line 82 of file GameFile.h.

◆ chunks

std::vector<Chunk> GameFile::chunks
protected

Definition at line 95 of file GameFile.h.

◆ curChunk

std::string GameFile::curChunk
private

Definition at line 102 of file GameFile.h.

◆ eof

bool GameFile::eof
protected

Definition at line 81 of file GameFile.h.

◆ filepath

std::string GameFile::filepath
protected

Definition at line 84 of file GameFile.h.

◆ m_fileDataId

int GameFile::m_fileDataId
protected

Definition at line 85 of file GameFile.h.

◆ m_useMemoryBuffer

bool GameFile::m_useMemoryBuffer
protected

Definition at line 96 of file GameFile.h.

◆ originalBuffer

unsigned char* GameFile::originalBuffer
private

Definition at line 101 of file GameFile.h.

◆ pointer

unsigned long long GameFile::pointer
protected

Definition at line 83 of file GameFile.h.

◆ size

unsigned long long GameFile::size
protected

Definition at line 83 of file GameFile.h.


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