YourGameLib
|
file and path related functions More...
Functions | |
int | readFile (const std::string &filename, std::vector< uint8_t > &dst) |
reads an entire file and returns it as a vector of bytes | |
int | readAssetFile (const std::string &filename, std::vector< uint8_t > &dst) |
reads an entire file (from asset file location) and returns it as a vector of bytes | |
int | readProjectFile (const std::string &filename, std::vector< uint8_t > &dst) |
reads an entire file (from project file location) and returns it as a vector of bytes | |
int | writeFile (const std::string &filename, const void *data, size_t numBytes) |
writes numBytes bytes from data to a file called filename, destination path determined by prefix ("a//", etc.), see readFile(). overwrites the file if it exists. | |
int | writeAssetFile (const std::string &filename, const void *data, size_t numBytes) |
writes numBytes bytes from data to a file called filename in the asset file location. overwrites the file if it exists | |
int | writeProjectFile (const std::string &filename, const void *data, size_t numBytes) |
writes numBytes bytes from data to a file called filename in the project file location. overwrites the file if it exists | |
void | setProjectPath (const std::string &path) |
sets path as current project directory | |
std::string | getBasePath (const std::string &pathRelative="") |
returns the full (absolut) path to the executable (base), extended by pathRelative | |
std::string | getAssetFilePath (const std::string &pathRelative="") |
returns the full (absolut) path to the assets directory, extended by pathRelative | |
std::string | getProjectFilePath (const std::string &pathRelative="") |
returns the full (absolut) path to the current project directory, extended by pathRelative | |
std::string | getFileLocation (const std::string &filepath) |
returns the location (path or prefix, such as a//) of a file, filepath points to | |
std::string | getFileName (const std::string &filepath) |
returns the actual file name of a file, filepath points to | |
std::string | getFileNameWithoutExtension (const std::string &filepath) |
returns the actual file name (w/o file extension) of a file, filepath points to | |
std::string | getFileExtension (const std::string &filepath) |
returns the file extension | |
std::vector< std::string > | ls (const std::string &pattern) |
returns list of directory content. accepts prefixes like readFile() does. accepts wildcard "*" for files (after last / in pattern) | |
file and path related functions
std::string yourgame::file::getAssetFilePath | ( | const std::string & | pathRelative = "" | ) |
returns the full (absolut) path to the assets directory, extended by pathRelative
std::string yourgame::file::getBasePath | ( | const std::string & | pathRelative = "" | ) |
returns the full (absolut) path to the executable (base), extended by pathRelative
std::string yourgame::file::getFileExtension | ( | const std::string & | filepath | ) |
returns the file extension
std::string yourgame::file::getFileLocation | ( | const std::string & | filepath | ) |
returns the location (path or prefix, such as a//) of a file, filepath points to
std::string yourgame::file::getFileName | ( | const std::string & | filepath | ) |
returns the actual file name of a file, filepath points to
std::string yourgame::file::getFileNameWithoutExtension | ( | const std::string & | filepath | ) |
returns the actual file name (w/o file extension) of a file, filepath points to
std::string yourgame::file::getProjectFilePath | ( | const std::string & | pathRelative = "" | ) |
returns the full (absolut) path to the current project directory, extended by pathRelative
std::vector< std::string > yourgame::file::ls | ( | const std::string & | pattern | ) |
returns list of directory content. accepts prefixes like readFile() does. accepts wildcard "*" for files (after last / in pattern)
int yourgame::file::readAssetFile | ( | const std::string & | filename, |
std::vector< uint8_t > & | dst | ||
) |
reads an entire file (from asset file location) and returns it as a vector of bytes
int yourgame::file::readFile | ( | const std::string & | filename, |
std::vector< uint8_t > & | dst | ||
) |
reads an entire file and returns it as a vector of bytes
a//
to load a file from asset file locationp//
to load a file from project file locationloadFile("a//file1.bin" ...) // loads file1.bin from assets
loadFile("p//file3.bin" ...) // loads file3.bin from project file location
loadFile("file4.bin" ...) // loads file4.bin from working directory
int yourgame::file::readProjectFile | ( | const std::string & | filename, |
std::vector< uint8_t > & | dst | ||
) |
reads an entire file (from project file location) and returns it as a vector of bytes
void yourgame::file::setProjectPath | ( | const std::string & | path | ) |
sets path as current project directory
int yourgame::file::writeAssetFile | ( | const std::string & | filename, |
const void * | data, | ||
size_t | numBytes | ||
) |
writes numBytes bytes from data to a file called filename in the asset file location. overwrites the file if it exists
int yourgame::file::writeFile | ( | const std::string & | filename, |
const void * | data, | ||
size_t | numBytes | ||
) |
writes numBytes bytes from data to a file called filename, destination path determined by prefix ("a//", etc.), see readFile(). overwrites the file if it exists.
int yourgame::file::writeProjectFile | ( | const std::string & | filename, |
const void * | data, | ||
size_t | numBytes | ||
) |
writes numBytes bytes from data to a file called filename in the project file location. overwrites the file if it exists