YourGameLib
Loading...
Searching...
No Matches
Namespaces | Functions
file.h File Reference
#include <cstdint>
#include <string>
#include <vector>
Include dependency graph for file.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  yourgame
 
namespace  yourgame::file
 file and path related functions
 

Functions

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
 
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::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 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::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::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 yourgame::file::setProjectPath (const std::string &path)
 sets path as current project directory
 
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::getAssetFilePath (const std::string &pathRelative="")
 returns the full (absolut) path to the assets directory, extended by pathRelative
 
std::string yourgame::file::getProjectFilePath (const std::string &pathRelative="")
 returns the full (absolut) path to the current project directory, extended by pathRelative
 
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::getFileExtension (const std::string &filepath)
 returns the file extension
 
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)