ChaiLove API
2.0.0
|
Provides an interface to the user's filesystem. More...
Public Member Functions | |
bool | load (const std::string &file) |
Loads and runs a .chai file. More... | |
std::string | read (const std::string &filename) |
Read the contents of a file. More... | |
bool | exists (const std::string &file) |
Check whether a file or directory exists. More... | |
int | getSize (const std::string &file) |
Get the size in bytes of a file. More... | |
FileInfo | getInfo (const std::string &path) |
Gets information about the specified file or directory. More... | |
FileData | newFileData (const std::string &filepath) |
Creates a new FileData from a file on the storage device. More... | |
FileData | newFileData (const std::string &contents, const std::string &name) |
Creates a new FileData object. More... | |
bool | unmount (const std::string &archive) |
Unmounts a zip file or folder previously mounted with love.filesystem.mount. More... | |
bool | mount (const std::string &archive, const std::string &mountpoint, bool appendToPath) |
Mounts a zip file or folder in the game's save directory for reading. More... | |
std::string | getSaveDirectory () |
Gets the path to the designated save directory. More... | |
std::vector< std::string > | getDirectoryItems (const std::string &dir) |
Returns all files and subdirectories in the directory. | |
bool | isDirectory (const std::string &filename) |
Check whether something is a directory. More... | |
bool | isFile (const std::string &filename) |
Checks whether something is a file. More... | |
bool | isSymlink (const std::string &filename) |
Checks whether something is a symlink. More... | |
bool | createDirectory (const std::string &name) |
Recursively creates a directory in the save directory. More... | |
bool | write (const std::string &name, const std::string &data) |
Write data to a file in the save directory. More... | |
std::vector< std::string > | lines (const std::string &filename, const std::string &delimiter) |
Iterate over the lines in a file, with the given delimiter. More... | |
std::string | getExecutablePath () |
Get the path to the executable that was used to run this application. More... | |
Provides an interface to the user's filesystem.
bool love::filesystem::createDirectory | ( | const std::string & | name | ) |
Recursively creates a directory in the save directory.
When called with "a/b" it creates both "a" and "a/b", if they don't exist already.
name | The directory to create. |
bool love::filesystem::exists | ( | const std::string & | file | ) |
Check whether a file or directory exists.
std::string love::filesystem::getExecutablePath | ( | ) |
Get the path to the executable that was used to run this application.
FileInfo love::filesystem::getInfo | ( | const std::string & | path | ) |
Gets information about the specified file or directory.
path | The path of the file to get information for. |
std::string love::filesystem::getSaveDirectory | ( | ) |
Gets the path to the designated save directory.
int love::filesystem::getSize | ( | const std::string & | file | ) |
Get the size in bytes of a file.
file | The file to get the size of. |
bool love::filesystem::isDirectory | ( | const std::string & | filename | ) |
bool love::filesystem::isFile | ( | const std::string & | filename | ) |
Checks whether something is a file.
bool love::filesystem::isSymlink | ( | const std::string & | filename | ) |
Checks whether something is a symlink.
std::vector<std::string> love::filesystem::lines | ( | const std::string & | filename, |
const std::string & | delimiter | ||
) |
Iterate over the lines in a file, with the given delimiter.
filename | The file to load the lines from. |
delimiter | ("\n") A string of characters representing what would be considered a new line. |
bool love::filesystem::load | ( | const std::string & | file | ) |
bool love::filesystem::mount | ( | const std::string & | archive, |
const std::string & | mountpoint, | ||
bool | appendToPath | ||
) |
Mounts a zip file or folder in the game's save directory for reading.
archive | The folder or zip file in the game's save directory to mount. |
mountpoint | The new path the archive will be mounted to. |
appendToPath | (true) Whether the archive will be searched when reading a filepath before or after already-mounted archives. This includes the game's source and save directories. |
FileData love::filesystem::newFileData | ( | const std::string & | contents, |
const std::string & | name | ||
) |
Creates a new FileData object.
contents | The contents fof the file. |
name | The name of the file. |
FileData love::filesystem::newFileData | ( | const std::string & | filepath | ) |
Creates a new FileData from a file on the storage device.
filepath | Path to the file. |
std::string love::filesystem::read | ( | const std::string & | filename | ) |
Read the contents of a file.
filename | The name (and path) of the file. |
bool love::filesystem::unmount | ( | const std::string & | archive | ) |
Unmounts a zip file or folder previously mounted with love.filesystem.mount.
archive | The archive that was previously mounted with love.filesystem.mount. |
bool love::filesystem::write | ( | const std::string & | name, |
const std::string & | data | ||
) |
Write data to a file in the save directory.
If the file existed already, it will be completely replaced by the new contents.
name | The name (and path) of the file. |
data | The string data to write to the file. |