Use filesystem::path::preferred_separator at compile time to remove a few preprocessor directives in main.cpp

This commit is contained in:
Username404-59 2021-10-08 16:27:09 +02:00
parent 429ed02483
commit a2b67298a4
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 9 additions and 8 deletions

View File

@ -2,6 +2,7 @@
#include <set>
#include "headers/Yerbacon.hpp"
#include <future>
#include <filesystem>
using namespace std;
#include "headers/misc.hpp"
@ -49,14 +50,14 @@ int main(int argc, char* argv[]) {
unsigned long lastSlash = 0;
unsigned long position1 = fileName.find_last_of('/');
if (cmp_not_equal(position1, string_view::npos)) {
#ifndef _WIN32
lastSlash = position1;
#else
unsigned long position2 = fileName.find_last_of('\\');
if (cmp_not_equal(position2, string_view::npos)) {
lastSlash = max(position1, position2);
}
#endif
if constexpr(filesystem::path::preferred_separator == '/') {
lastSlash = position1;
} else {
unsigned long position2 = fileName.find_last_of(filesystem::path::preferred_separator);
if (cmp_not_equal(position2, string_view::npos)) {
lastSlash = max(position1, position2);
}
}
}
resultingPair.first = fileName.substr(lastSlash + 1);
resultingPair.second.emplace(error);