add file_util

This commit is contained in:
scawful
2024-08-12 10:30:36 -04:00
parent 45ab5a8a2a
commit cfbe0848ca
2 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#include "file_util.h"
#if defined(_WIN32)
#include <windows.h>
#else
#include <dirent.h>
#include <sys/stat.h>
#endif
#include <fstream>
#include <sstream>
namespace yaze {
namespace app {
namespace core {
std::string LoadFile(const std::string& filename) {
std::string contents;
// TODO: Load a file based on the platform and add error handling
return contents;
}
} // namespace core
} // namespace app
} // namespace yaze

View File

@@ -0,0 +1,32 @@
#ifndef YAZE_APP_CORE_UTILS_FILE_UTIL_H
#define YAZE_APP_CORE_UTILS_FILE_UTIL_H
#include <string>
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);
}
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 LoadFile(const std::string& filename);
} // namespace core
} // namespace app
} // namespace yaze
#endif // YAZE_APP_CORE_UTILS_FILE_UTIL_H