Use filesystem::path::preferred_separator at compile time to remove a few preprocessor directives in main.cpp
This commit is contained in:
parent
429ed02483
commit
a2b67298a4
17
src/main.cpp
17
src/main.cpp
|
@ -2,6 +2,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "headers/Yerbacon.hpp"
|
#include "headers/Yerbacon.hpp"
|
||||||
#include <future>
|
#include <future>
|
||||||
|
#include <filesystem>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "headers/misc.hpp"
|
#include "headers/misc.hpp"
|
||||||
|
@ -49,14 +50,14 @@ int main(int argc, char* argv[]) {
|
||||||
unsigned long lastSlash = 0;
|
unsigned long lastSlash = 0;
|
||||||
unsigned long position1 = fileName.find_last_of('/');
|
unsigned long position1 = fileName.find_last_of('/');
|
||||||
if (cmp_not_equal(position1, string_view::npos)) {
|
if (cmp_not_equal(position1, string_view::npos)) {
|
||||||
#ifndef _WIN32
|
if constexpr(filesystem::path::preferred_separator == '/') {
|
||||||
lastSlash = position1;
|
lastSlash = position1;
|
||||||
#else
|
} else {
|
||||||
unsigned long position2 = fileName.find_last_of('\\');
|
unsigned long position2 = fileName.find_last_of(filesystem::path::preferred_separator);
|
||||||
if (cmp_not_equal(position2, string_view::npos)) {
|
if (cmp_not_equal(position2, string_view::npos)) {
|
||||||
lastSlash = max(position1, position2);
|
lastSlash = max(position1, position2);
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
resultingPair.first = fileName.substr(lastSlash + 1);
|
resultingPair.first = fileName.substr(lastSlash + 1);
|
||||||
resultingPair.second.emplace(error);
|
resultingPair.second.emplace(error);
|
||||||
|
|
Loading…
Reference in New Issue