From 3d56bcb10fbc0002f2650b78349a7d313a8e1c46 Mon Sep 17 00:00:00 2001 From: Username404 Date: Mon, 20 Dec 2021 19:18:07 +0100 Subject: [PATCH] Use generic_category::message() instead of strerror() in filefuncs.cpp --- src/etc/filefuncs.cpp | 16 +++++++++------- src/headers/Yerbacon.hpp | 5 ----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/etc/filefuncs.cpp b/src/etc/filefuncs.cpp index 2e81c9d..c556747 100644 --- a/src/etc/filefuncs.cpp +++ b/src/etc/filefuncs.cpp @@ -1,17 +1,19 @@ #include #include -#include +#include using namespace std; string getFileContent(const string& file, const bool& parallel) { ifstream fileStream(file, ios::in); - string lineinput, fullinput; - if (fileStream.is_open()) while (getline(fileStream, lineinput)) { - fullinput.append(lineinput += '\n'); - } else throw Yerbacon::Exception("Could not open \"" + file + "\"" + ((not parallel) ? string(" : ").append(strerror(errno)) : ".")); // TODO: Use a thread-safe function when the parallel mode is in use - fileStream.close(); - return fullinput; + if (not fileStream.fail()) { + string lineinput, fullinput; + while (getline(fileStream, lineinput)) { + fullinput.append(lineinput += '\n'); + } + fileStream.close(); + return fullinput; + } else throw Yerbacon::Exception("Could not open \"" + file + "\" : " + generic_category().message(errno)); } void outputFileContent(const string& file, const string_view content) { diff --git a/src/headers/Yerbacon.hpp b/src/headers/Yerbacon.hpp index b1c09f2..adb5abd 100644 --- a/src/headers/Yerbacon.hpp +++ b/src/headers/Yerbacon.hpp @@ -18,11 +18,6 @@ #error "A valid std::threads implementation is required" #endif -#ifdef _MSC_VER -// #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1 -#define _CRT_SECURE_NO_WARNINGS 1 -#endif - #include #if not defined(__cpp_lib_concepts) || not defined(__cpp_lib_integer_comparison_functions) #error "The current standard library is incomplete"