From a2b67298a41c31aab895de492259a63c5b2edc5f Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Fri, 8 Oct 2021 16:27:09 +0200 Subject: [PATCH] Use filesystem::path::preferred_separator at compile time to remove a few preprocessor directives in main.cpp --- src/main.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f6a24a8..a323611 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@ #include #include "headers/Yerbacon.hpp" #include +#include 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);