Update LoadFile, GetFileExtension, GetFileName

This commit is contained in:
scawful
2024-11-02 10:25:30 -05:00
parent 665d58aa97
commit 0d5618a5ba
2 changed files with 67 additions and 24 deletions

View File

@@ -7,26 +7,18 @@ namespace yaze {
namespace app {
namespace core {
std::string GetFileExtension(const std::string& filename) {
size_t dot = filename.find_last_of(".");
if (dot == std::string::npos) {
return "";
}
return filename.substr(dot + 1);
}
enum class Platform { kUnknown, kMacOS, kiOS, kWindows, kLinux };
std::string GetFileName(const std::string& filename) {
size_t slash = filename.find_last_of("/");
if (slash == std::string::npos) {
return filename;
}
return filename.substr(slash + 1);
}
std::string GetFileExtension(const std::string &filename);
std::string GetFileName(const std::string &filename);
std::string LoadFile(const std::string &filename, Platform platform);
std::string GetConfigDirectory(Platform platform);
std::string LoadFile(const std::string& filename);
void SaveFile(const std::string &filename, const std::string &data,
Platform platform);
} // namespace core
} // namespace app
} // namespace yaze
} // namespace core
} // namespace app
} // namespace yaze
#endif // YAZE_APP_CORE_UTILS_FILE_UTIL_H
#endif // YAZE_APP_CORE_UTILS_FILE_UTIL_H