filesys::

Summary
Gets a listing of the CD directories on a system (not supported on all systems)
Get the path to the directory that the application is running in.
Get the path to the directory that the OS specifies for the user’s home.
Attempts to add a directory to the search path.
Removes a directory from the search path, if it exists on the path.
Obtain the currently configured search path.
Sets the writing directory, used by mkdir and remove.
Gets the writing directory.
Attempts to create a directory.
Attempts to remove a file or directory.
Lists the contents of a directory.
Checks if a file/directory exists.
Checks if a name refers to a directory.
Checks if a name refers to a symbolic link.
Gets the system standard directory separator.
Enables or disables symbolic linking.
Gets last modification time for a file.

System Directories

getCDDirs

std::vector<std::string> getCDDirs()

Gets a listing of the CD directories on a system (not supported on all systems)

Returns

A vector of strings containing the path to the CD directories.

getBaseDir

std::string getBaseDir()

Get the path to the directory that the application is running in.

Returns

Path to directory that application is running from.

getUserDir

std::string getUserDir()

Get the path to the directory that the OS specifies for the user’s home.

Returns

Path to user’s home directory.

Search Path

addToSearchPath

void addToSearchPath(const std::string &dir,  
bool append = true)

Attempts to add a directory to the search path.

Parameters

dirDirectory to add to the search path
appendoptional: if true, directory will be added to end of path (default) if false, directory will be added to front of path

See Also

removeFromSearchPath getSearchPath

removeFromSearchPath

void removeFromSearchPath(const std::string &dir)

Removes a directory from the search path, if it exists on the path.

Parameters

dirDirectory to remove from the search path, if it doesn’t exist nothing happens.

See Also

addToSearchPath getSearchPath

getSearchPath

std::vector<std::string> getSearchPath()

Obtain the currently configured search path.

Returns

List of strings in search path.

See Also

addToSearchPath removeFromSearchPath

Manipulation

setWriteDir

void setWriteDir(const std::string &dir)

Sets the writing directory, used by mkdir and remove.

Parameters

dirDirectory to make writeable

See Also

getWriteDir

getWriteDir

std::string getWriteDir()

Gets the writing directory.

Returns

Writable directory, if set.

See Also

setWriteDir

mkdir

bool mkdir(const std::string &dir)

Attempts to create a directory.

Parameters

dirname of directory to create

Returns

true iff directory was created, false if not

remove

bool remove(const std::string &item)

Attempts to remove a file or directory.

Parameters

removename of file or directory to remove

Returns

true iff file/directory was removed, false if not

Searching

listDir

std::vector<std::string> listDir(const std::string &dir)

Lists the contents of a directory.

Parameters

dirname of directory to get contents of

Returns

list of strings representing items found in ‘dir’

exists

bool exists(const std::string &item)

Checks if a file/directory exists.

Parameters

itemfile/directory to check existance of

Returns

true iff file/directory exists, false if not

isDir

bool isDir(const std::string &item)

Checks if a name refers to a directory.

Parameters

itemname to check

Returns

true iff item is a directory, false if not

isSymbolicLink

bool isSymbolicLink(const std::string &item)

Checks if a name refers to a symbolic link.

Parameters

itemname to check

Returns

true iff item is a symbolic link, false if not

Other

getDirSeparator

std::string getDirSeparator()

Gets the system standard directory separator.  (/ on unix, \\ on windows, : on MacOS)

Returns

System directory separator.

permitSymbolicLinks

void permitSymbolicLinks(bool allow)

Enables or disables symbolic linking.  (which is off by default)

Parameters

allowtrue if you wish to enable linking, false if you wish to disable it

getModTime

PHYSFS_sint64 getModTime(const std::string &item)

Gets last modification time for a file.

Parameters

itemname of item to get last modification time of

Returns

Last modification time of a file in seconds since the epoch.

std::vector<std::string> getCDDirs()
Gets a listing of the CD directories on a system (not supported on all systems)
std::string getBaseDir()
Get the path to the directory that the application is running in.
std::string getUserDir()
Get the path to the directory that the OS specifies for the user’s home.
void addToSearchPath(const std::string &dir,  
bool append = true)
Attempts to add a directory to the search path.
void removeFromSearchPath(const std::string &dir)
Removes a directory from the search path, if it exists on the path.
std::vector<std::string> getSearchPath()
Obtain the currently configured search path.
void setWriteDir(const std::string &dir)
Sets the writing directory, used by mkdir and remove.
bool mkdir(const std::string &dir)
Attempts to create a directory.
bool remove(const std::string &item)
Attempts to remove a file or directory.
std::string getWriteDir()
Gets the writing directory.
std::vector<std::string> listDir(const std::string &dir)
Lists the contents of a directory.
bool exists(const std::string &item)
Checks if a file/directory exists.
bool isDir(const std::string &item)
Checks if a name refers to a directory.
bool isSymbolicLink(const std::string &item)
Checks if a name refers to a symbolic link.
std::string getDirSeparator()
Gets the system standard directory separator.
void permitSymbolicLinks(bool allow)
Enables or disables symbolic linking.
PHYSFS_sint64 getModTime(const std::string &item)
Gets last modification time for a file.