add file_util
This commit is contained in:
25
src/app/core/utils/file_util.cc
Normal file
25
src/app/core/utils/file_util.cc
Normal 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
|
||||
32
src/app/core/utils/file_util.h
Normal file
32
src/app/core/utils/file_util.h
Normal 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
|
||||
Reference in New Issue
Block a user