enginefs replaced with EnginePaths class + command line arguments

This commit is contained in:
MihailRis
2023-11-26 14:07:18 +03:00
parent 7a39ba6b2e
commit fe220ee172
9 changed files with 54 additions and 85 deletions
-40
View File
@@ -1,40 +0,0 @@
#include "engine_files.h"
#include <filesystem>
#include <sstream>
#include "../typedefs.h"
namespace fs = std::filesystem;
using std::string;
using fs::path;
path enginefs::get_screenshot_file(string ext) {
path folder = SCREENSHOTS_FOLDER;
if (!fs::is_directory(folder)) {
fs::create_directory(folder);
}
auto t = std::time(nullptr);
auto tm = *std::localtime(&t);
const char* format = "%Y-%m-%d_%H-%M-%S";
std::stringstream ss;
ss << std::put_time(&tm, format);
string datetimestr = ss.str();
path filename = folder/path("screenshot-"+datetimestr+"."+ext);
uint index = 0;
while (fs::exists(filename)) {
filename = folder/path("screenshot-"+datetimestr+"-"+std::to_string(index)+"."+ext);
index++;
}
return filename;
}
path enginefs::get_worlds_folder() {
return path("worlds");
}
bool enginefs::is_world_name_used(std::string name) {
return fs::exists(enginefs::get_worlds_folder()/fs::u8path(name));
}
-15
View File
@@ -1,15 +0,0 @@
#ifndef FILES_ENGINE_FILES_H_
#define FILES_ENGINE_FILES_H_
#include <string>
#include <filesystem>
#define SCREENSHOTS_FOLDER "screenshots"
namespace enginefs {
extern std::filesystem::path get_screenshot_file(std::string ext);
extern std::filesystem::path get_worlds_folder();
extern bool is_world_name_used(std::string name);
}
#endif // FILES_ENGINE_FILES_H_