13namespace fs = std::filesystem;
16 return fs::path(filename).extension().string();
20 return fs::path(filename).filename().string();
23std::string
LoadFile(
const std::string &filename) {
25 std::ifstream file(filename);
27 std::stringstream buffer;
28 buffer << file.rdbuf();
29 contents = buffer.str();
33 throw std::runtime_error(
"Could not open file: " + filename);
40 if (!config_dir.ok()) {
44 fs::path filepath = *config_dir / filename;
46 std::ifstream file(filepath);
48 std::stringstream buffer;
49 buffer << file.rdbuf();
50 contents = buffer.str();
56void SaveFile(
const std::string &filename,
const std::string &contents) {
58 if (!config_dir.ok()) {
62 fs::path filepath = *config_dir / filename;
63 std::ofstream file(filepath);
74 return kBundlePath + resource_path;
void SaveFile(const std::string &filename, const std::string &contents)
std::string GetFileName(const std::string &filename)
Gets the filename from a full path.
std::string GetResourcePath(const std::string &resource_path)
std::string LoadFileFromConfigDir(const std::string &filename)
Loads a file from the user's config directory.
std::string GetFileExtension(const std::string &filename)
Gets the file extension from a filename.
std::string GetBundleResourcePath()
GetBundleResourcePath returns the path to the bundle resource directory. Specific to MacOS.
std::string LoadFile(const std::string &filename)
Loads the entire contents of a file into a string.
Main namespace for the application.