FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
FIFE::DAT2 Class Reference

VFSource for the Fallout2 DAT file format. More...

#include <dat2.h>

+ Inheritance diagram for FIFE::DAT2:
+ Collaboration diagram for FIFE::DAT2:

Public Member Functions

 DAT2 (VFS *vfs, const std::string &path)
 Constructor Create a VFSSource for a Fallout2 DAT file. More...
 
bool fileExists (const std::string &name) const
 check if the given file exists More...
 
RawDataopen (const std::string &file) const
 open a file inside this source More...
 
const RawDataDAT2::s_infogetInfo (const std::string &name) const
 Get Information needed to unpack and extract data. More...
 
std::set< std::string > listFiles (const std::string &pathstr) const
 list all files in a directory of this source More...
 
std::set< std::string > listDirectories (const std::string &pathstr) const
 list all directories in a directory of this source More...
 
- Public Member Functions inherited from FIFE::VFSSource
 VFSSource (VFS *vfs)
 
virtual ~VFSSource ()
 
VFSgetVFS () const
 get the VFS this source is associated with. More...
 

Private Types

typedef std::map< std::string, RawDataDAT2::s_infotype_filelist
 

Private Member Functions

void readFileEntry () const
 read a bunch of file entries More...
 
type_filelist::const_iterator findFileEntry (const std::string &name) const
 find a file entry More...
 
std::set< std::string > list (const std::string &pathstr, bool dirs) const
 
 DAT2 (const DAT2 &)
 
DAT2operator= (const DAT2 &)
 

Private Attributes

std::string m_datpath
 
std::unique_ptr< RawDatam_data
 
type_filelist m_filelist
 
uint32_t m_filecount
 number of file entries to read More...
 
uint32_t m_currentIndex
 current index in file More...
 
Timer m_timer
 lazy loading timer More...
 

Additional Inherited Members

- Protected Member Functions inherited from FIFE::VFSSource
std::string fixPath (std::string path) const
 

Detailed Description

VFSource for the Fallout2 DAT file format.

Implements a kind of lazy initializing, by reading the file list in chunks. Behaviour is the same as if it wouldn't do this, but startup is very fast. But a open/fileExists call with a filename that doesn't exist, does trigger completely loading the file entries.

See also
MFFalloutDAT1

Definition at line 59 of file dat2.h.

Member Typedef Documentation

◆ type_filelist

typedef std::map<std::string, RawDataDAT2::s_info> FIFE::DAT2::type_filelist
private

Definition at line 84 of file dat2.h.

Constructor & Destructor Documentation

◆ DAT2() [1/2]

FIFE::DAT2::DAT2 ( VFS vfs,
const std::string &  path 
)

Constructor Create a VFSSource for a Fallout2 DAT file.

Parameters
vfsA pointer to the VFS.
pathA Fallout2 DAT file - e.g. master.DAT

Definition at line 42 of file dat2.cpp.

References FIFE::_log, FL_LOG, m_currentIndex, m_data, m_filecount, m_timer, readFileEntry(), FIFE::Timer::setCallback(), FIFE::Timer::setInterval(), and FIFE::Timer::start().

◆ DAT2() [2/2]

FIFE::DAT2::DAT2 ( const DAT2 )
private

Member Function Documentation

◆ fileExists()

bool FIFE::DAT2::fileExists ( const std::string &  file) const
virtual

check if the given file exists

Parameters
filefilename to check
Returns
true if it exists, false otherwise

Implements FIFE::VFSSource.

Definition at line 114 of file dat2.cpp.

References findFileEntry(), and m_filelist.

◆ findFileEntry()

DAT2::type_filelist::const_iterator FIFE::DAT2::findFileEntry ( const std::string &  name) const
private

find a file entry

Definition at line 126 of file dat2.cpp.

References FIFE::_log, FL_LOG, m_datpath, m_filecount, m_filelist, and readFileEntry().

Referenced by fileExists(), and getInfo().

+ Here is the caller graph for this function:

◆ getInfo()

const RawDataDAT2::s_info & FIFE::DAT2::getInfo ( const std::string &  name) const

Get Information needed to unpack and extract data.

See also
MFFalloutDAT1::getInfo

Definition at line 118 of file dat2.cpp.

References findFileEntry(), and m_filelist.

Referenced by open().

+ Here is the caller graph for this function:

◆ list()

std::set< std::string > FIFE::DAT2::list ( const std::string &  pathstr,
bool  dirs 
) const
private

Definition at line 164 of file dat2.cpp.

References m_filecount, m_filelist, and readFileEntry().

Referenced by listDirectories(), and listFiles().

+ Here is the caller graph for this function:

◆ listDirectories()

std::set< std::string > FIFE::DAT2::listDirectories ( const std::string &  path) const
virtual

list all directories in a directory of this source

Parameters
pathpath to list directories in Will return an empty list on any error

Implements FIFE::VFSSource.

Definition at line 160 of file dat2.cpp.

References list().

◆ listFiles()

std::set< std::string > FIFE::DAT2::listFiles ( const std::string &  path) const
virtual

list all files in a directory of this source

Parameters
pathpath to list files in Will return an empty list on any error

Implements FIFE::VFSSource.

Definition at line 156 of file dat2.cpp.

References list().

◆ open()

RawData * FIFE::DAT2::open ( const std::string &  file) const
virtual

open a file inside this source

Parameters
filethe file to open
Returns
a new RawData*
Exceptions
CannotOpenFileif the file can't be found

Implements FIFE::VFSSource.

Definition at line 109 of file dat2.cpp.

References getInfo(), FIFE::VFSSource::getVFS(), and m_datpath.

◆ operator=()

DAT2& FIFE::DAT2::operator= ( const DAT2 )
private

◆ readFileEntry()

void FIFE::DAT2::readFileEntry ( ) const
private

Member Data Documentation

◆ m_currentIndex

uint32_t FIFE::DAT2::m_currentIndex
mutableprivate

current index in file

Definition at line 90 of file dat2.h.

Referenced by DAT2(), and readFileEntry().

◆ m_data

std::unique_ptr<RawData> FIFE::DAT2::m_data
mutableprivate

Definition at line 83 of file dat2.h.

Referenced by DAT2(), and readFileEntry().

◆ m_datpath

std::string FIFE::DAT2::m_datpath
private

Definition at line 82 of file dat2.h.

Referenced by findFileEntry(), open(), and readFileEntry().

◆ m_filecount

uint32_t FIFE::DAT2::m_filecount
mutableprivate

number of file entries to read

Definition at line 88 of file dat2.h.

Referenced by DAT2(), findFileEntry(), list(), and readFileEntry().

◆ m_filelist

type_filelist FIFE::DAT2::m_filelist
mutableprivate

Definition at line 85 of file dat2.h.

Referenced by fileExists(), findFileEntry(), getInfo(), list(), and readFileEntry().

◆ m_timer

Timer FIFE::DAT2::m_timer
mutableprivate

lazy loading timer

Definition at line 92 of file dat2.h.

Referenced by DAT2(), and readFileEntry().


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