wowlib
0.0.0
Read & write World of Warcraft client files — a C++26 core
Toggle main menu visibility
Loading...
Searching...
No Matches
path.cpp
Go to the documentation of this file.
1
#include <
wowlib/core/path.hpp
>
2
3
namespace
wowlib
{
4
std::string
normalizePath
(std::string_view path) {
5
std::string result;
6
result.reserve(path.size());
7
8
for
(
char
c : path) {
9
if
(c ==
'/'
) c =
'\\'
;
10
else
if
(c >=
'A'
&& c <=
'Z'
) c =
static_cast<
char
>
(c -
'A'
+
'a'
);
11
12
// collapse duplicate separators, drop a leading one
13
if
(c ==
'\\'
&& (result.empty() || result.back() ==
'\\'
))
continue
;
14
15
result.push_back(c);
16
}
17
18
if
(!result.empty() && result.back() ==
'\\'
) result.pop_back();
19
20
return
result;
21
}
22
23
std::string
toNativeRelative
(std::string_view canonical) {
24
std::string result{canonical};
25
for
(
char
& c : result)
26
if
(c ==
'\\'
) c =
'/'
;
27
return
result;
28
}
29
}
wowlib
Definition
detail.hpp:29
wowlib::normalizePath
std::string normalizePath(std::string_view path)
Canonicalize a client-internal file path.
Definition
path.cpp:4
wowlib::toNativeRelative
std::string toNativeRelative(std::string_view canonical)
Convert a canonical path to a forward-slash relative path for use on the native filesystem (project-d...
Definition
path.cpp:23
path.hpp
Client-internal path canonicalization.
src
wowlib
core
path.cpp
Generated by
1.17.0