Use generic_category::message() instead of strerror() in filefuncs.cpp

This commit is contained in:
Username404 2021-12-20 19:18:07 +01:00
parent b8223e14f0
commit 3d56bcb10f
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 9 additions and 12 deletions

View File

@ -1,17 +1,19 @@
#include <fstream>
#include <iostream>
#include <cstring>
#include <system_error>
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) {

View File

@ -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 <version>
#if not defined(__cpp_lib_concepts) || not defined(__cpp_lib_integer_comparison_functions)
#error "The current standard library is incomplete"