Mana
Loading...
Searching...
No Matches
Classes | Functions
FS Namespace Reference

These functions wrap PHYSFS functions to provide a more user-friendly interface and to limit the direct use of the PHYSFS API to a single file. More...

Classes

class  File
 File wrapper class to provide a more convenient API and automatic closing. More...
 
class  Files
 Helper class to iterate over the files in a directory. More...
 

Functions

bool init (const char *argv0)
 
void deinit ()
 
const char * getDirSeparator ()
 
const char * getBaseDir ()
 
const char * getUserDir ()
 
const char * getPrefDir (const char *org, const char *app)
 
bool setWriteDir (const std::string &path)
 Sets the write directory.
 
bool addToSearchPath (const std::string &path, bool append)
 Adds a directory or archive to the search path.
 
bool exists (const std::string &path)
 Checks whether the given file or directory exists in the search path.
 
std::optional< const char * > getRealDir (const std::string &path)
 
bool isDirectory (const std::string &path)
 Checks whether the given path is a directory.
 
bool mkdir (const std::string &path)
 Creates a directory in the write path.
 
Files enumerateFiles (const std::string &dir)
 Returns a list of files in the given directory.
 
File openWrite (const std::string &path)
 
File openAppend (const std::string &path)
 
File openRead (const std::string &path)
 
const char * getLastError ()
 
SDL_RWops * openRWops (const std::string &path)
 
SDL_RWops * openBufferedRWops (const std::string &path, PHYSFS_uint64 bufferSize=2048)
 Creates a buffered SDL_RWops.
 
void * loadFile (const std::string &path, size_t &datasize)
 

Detailed Description

These functions wrap PHYSFS functions to provide a more user-friendly interface and to limit the direct use of the PHYSFS API to a single file.

Function Documentation

◆ addToSearchPath()

bool FS::addToSearchPath ( const std::string &  path,
bool  append 
)
inline

Adds a directory or archive to the search path.

If append is true then the directory is added to the end of the search path, otherwise it is added at the front.

Returns
true on success, false otherwise.

Definition at line 85 of file filesystem.h.

◆ deinit()

void FS::deinit ( )
inline

Definition at line 42 of file filesystem.h.

◆ enumerateFiles()

Files FS::enumerateFiles ( const std::string &  dir)
inline

Returns a list of files in the given directory.

Definition at line 153 of file filesystem.h.

◆ exists()

bool FS::exists ( const std::string &  path)
inline

Checks whether the given file or directory exists in the search path.

Definition at line 93 of file filesystem.h.

◆ getBaseDir()

const char * FS::getBaseDir ( )
inline

Definition at line 52 of file filesystem.h.

◆ getDirSeparator()

const char * FS::getDirSeparator ( )
inline

Definition at line 47 of file filesystem.h.

◆ getLastError()

const char * FS::getLastError ( )
inline

Definition at line 252 of file filesystem.h.

◆ getPrefDir()

const char * FS::getPrefDir ( const char *  org,
const char *  app 
)
inline

Definition at line 62 of file filesystem.h.

◆ getRealDir()

std::optional< const char * > FS::getRealDir ( const std::string &  path)
inline

Definition at line 98 of file filesystem.h.

◆ getUserDir()

const char * FS::getUserDir ( )
inline

Definition at line 57 of file filesystem.h.

◆ init()

bool FS::init ( const char *  argv0)
inline

Definition at line 37 of file filesystem.h.

◆ isDirectory()

bool FS::isDirectory ( const std::string &  path)
inline

Checks whether the given path is a directory.

Definition at line 107 of file filesystem.h.

◆ loadFile()

void * FS::loadFile ( const std::string &  path,
size_t &  datasize 
)
inline

Definition at line 288 of file filesystem.h.

◆ mkdir()

bool FS::mkdir ( const std::string &  path)
inline

Creates a directory in the write path.

Definition at line 120 of file filesystem.h.

◆ openAppend()

File FS::openAppend ( const std::string &  path)
inline

Definition at line 242 of file filesystem.h.

◆ openBufferedRWops()

SDL_RWops * FS::openBufferedRWops ( const std::string &  path,
PHYSFS_uint64  bufferSize = 2048 
)
inline

Creates a buffered SDL_RWops.

Used to workaround a performance issue when SDL_mixer is using stb_vorbis, in which case the file is read one byte at a time.

See https://github.com/libsdl-org/SDL_mixer/issues/670

Definition at line 274 of file filesystem.h.

◆ openRead()

File FS::openRead ( const std::string &  path)
inline

Definition at line 247 of file filesystem.h.

◆ openRWops()

SDL_RWops * FS::openRWops ( const std::string &  path)
inline

Definition at line 261 of file filesystem.h.

◆ openWrite()

File FS::openWrite ( const std::string &  path)
inline

Definition at line 237 of file filesystem.h.

◆ setWriteDir()

bool FS::setWriteDir ( const std::string &  path)
inline

Sets the write directory.

Parameters
pathThe path of the directory to be added.
Returns
true on success, false otherwise.

Definition at line 73 of file filesystem.h.