FILE to fstream

Lets move away from  the c standart FILE and use c++ fstream as well as c++17 filesystem!!!
This commit is contained in:
2023-08-28 17:03:00 +02:00
parent 5cca34ede4
commit 267f9ce5c3
8 changed files with 52 additions and 49 deletions

View File

@@ -1,5 +1,6 @@
#include <renderd7/log.hpp>
#include <fstream>
#include <filesystem>
#include <memory>
std::string Log::format(const std::string &fmt_str, ...) {
@@ -28,12 +29,12 @@ void Log::Init(const char *filename) {
printf("%s\n", filename);
std::string fn = filename;
std::string name = fn + ".txt";
this->filename = name.c_str();
if ((access(name.c_str(), F_OK) == 0)) {
this->filename = name;
if(std::filesystem::exists(name)) {
// Do nothing
} else {
FILE *logfile = fopen((name.c_str()), "w");
fclose(logfile);
std::fstream f(name, std::ios::out);
f.close();
}
}