33std::string_view
fileName(std::string_view path)
35 std::size_t lastSlash = path.rfind(
'/');
36 std::size_t lastBackSlash = path.rfind(
'\\');
37 std::size_t lastSeparator;
38 if (lastSlash == std::string::npos && lastBackSlash == std::string::npos) {
40 }
else if (lastSlash == std::string::npos) {
41 lastSeparator = lastBackSlash;
42 }
else if (lastBackSlash == std::string::npos) {
43 lastSeparator = lastSlash;
45 lastSeparator = lastSlash > lastBackSlash ? lastSlash : lastBackSlash;
47 return path.substr(lastSeparator + 1);
55 std::size_t lastSlash = path.rfind(
'/');
56 std::size_t lastBackSlash = path.rfind(
'\\');
57 std::size_t lastSeparator;
58 if (lastSlash == std::string::npos && lastBackSlash == std::string::npos) {
59 return std::string_view();
60 }
else if (lastSlash == std::string::npos) {
61 lastSeparator = lastBackSlash;
62 }
else if (lastBackSlash == std::string::npos) {
63 lastSeparator = lastSlash;
65 lastSeparator = lastSlash > lastBackSlash ? lastSlash : lastBackSlash;
67 return path.substr(0, lastSeparator + 1);