CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
iso_filesystem Class Reference

Layer for reading Theme Hospital files out of an .iso disk image. More...

#include <iso_fs.h>

Public Types

using file_handle = int
 

Public Member Functions

 iso_filesystem (const char *path, char pathSeparator='/')
 Load an .iso disk image and search for Theme Hospital data files.
 
 ~iso_filesystem ()=default
 
std::string_view get_error () const
 Get the reason for the most recent failure.
 
file_handle find_file (const char *sPath) const
 Find a file in the loaded .iso disk image.
 
void visit_directory_files (const char *sPath, void(*fnCallback)(void *, const char *, const char *), void *pCallbackData) const
 Iterate all files of the .iso disk image within a given directory.
 
uint32_t get_file_start (file_handle iFile) const
 Get the byte offset of the start of the file in the loaded .iso.
 
uint32_t get_file_size (file_handle iFile) const
 Get the size (in bytes) of a file in the loaded .iso disk image.
 
bool get_file_data (file_handle iFile, uint8_t *pBuffer)
 Get the contents of a file in the loaded .iso disk image.
 

Static Public Member Functions

static bool is_handle_good (file_handle x)
 Test if a file handle from find_file() is good or is invalid.
 

Static Public Attributes

static constexpr size_t min_sector_size = 2048
 

Detailed Description

Layer for reading Theme Hospital files out of an .iso disk image.

An instance of this class can read files which contain an ISO 9660 file system (as described at http://alumnus.caltech.edu/~pje/iso9660.html and http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf) which are typically called iso disk images. Once given a disk image, it searches for the Theme Hospital data files, and can then be used to read these data files.

Member Typedef Documentation

◆ file_handle

Constructor & Destructor Documentation

◆ iso_filesystem()

iso_filesystem::iso_filesystem ( const char path,
char  pathSeparator = '/' 
)
explicit

Load an .iso disk image and search for Theme Hospital data files.

Parameters
pathPath to the .iso disk image to load
pathSeparatorThe character to be used between components in file paths. Defaults to '/'.
Exceptions
std::runtime_errorif the file could not be opened

◆ ~iso_filesystem()

iso_filesystem::~iso_filesystem ( )
default

Member Function Documentation

◆ find_file()

iso_filesystem::file_handle iso_filesystem::find_file ( const char sPath) const

Find a file in the loaded .iso disk image.

If (and only if) the given file could not be found, then isHandleGood() will return false on the returned handle.

◆ get_error()

std::string_view iso_filesystem::get_error ( ) const

Get the reason for the most recent failure.

Can be called after get_file_data() return false.

◆ get_file_data()

bool iso_filesystem::get_file_data ( file_handle  iFile,
uint8_t *  pBuffer 
)

Get the contents of a file in the loaded .iso disk image.

Parameters
iFileA file handle returned by find_file()
pBufferThe buffer to place the resulting data in
Returns
true on success, false on failure - call getError() for reason

◆ get_file_size()

uint32_t iso_filesystem::get_file_size ( file_handle  iFile) const

Get the size (in bytes) of a file in the loaded .iso disk image.

Parameters
iFileA file handle returned by find_file()

◆ get_file_start()

uint32_t iso_filesystem::get_file_start ( file_handle  iFile) const

Get the byte offset of the start of the file in the loaded .iso.

Parameters
iFileA file handle returned by find_file()

◆ is_handle_good()

static bool iso_filesystem::is_handle_good ( file_handle  x)
inlinestatic

Test if a file handle from find_file() is good or is invalid.

◆ visit_directory_files()

void iso_filesystem::visit_directory_files ( const char sPath,
void(*)(void *, const char *, const char *)  fnCallback,
void pCallbackData 
) const

Iterate all files of the .iso disk image within a given directory.

Parameters
sPathThe directory to iterate
fnCallbackThe function to be called for each file. The first parameter to this function is pCallbackData. The second is the name of a file which is in sPath.
pCallbackDataOpaque value to be called to fnCallback.

Member Data Documentation

◆ min_sector_size

constexpr size_t iso_filesystem::min_sector_size = 2048
staticconstexpr

Sector sizes can vary, but they must be powers of two, and the minimum size is 2048.


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