Skip to content

Commit 3580097

Browse files
committed
fixup
1 parent 1d7f86a commit 3580097

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/normalize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fs_drop_slash(std::string_view in)
118118

119119
if(fs_is_windows()){
120120
// Extended-length or device path
121-
if(in.length() >= 4 && fs_win32_is_ext_path(in)){
121+
if(fs_win32_is_ext_path(in)){
122122
i = 4;
123123
#if defined(_WIN32)
124124
} else if (PathIsUNCA(in.data())){

src/pure.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool fs_is_absolute(std::string_view path)
6969
return false;
7070

7171
// Extended-length or device path
72-
if(path.length() >= 4 && fs_win32_is_ext_path(path))
72+
if(fs_win32_is_ext_path(path))
7373
return true;
7474
#if defined(_WIN32)
7575
if(PathIsUNCA(path.data()))
@@ -109,8 +109,15 @@ std::string fs_root(std::string_view path)
109109
if (std::string r = fs_root_name(path);
110110
r.empty())
111111
return fs_slash_first(path) ? "/" : "";
112-
else
113-
return (fs_is_windows() && r == path) ? r : r + "/";
112+
else if (fs_is_windows()) {
113+
if (path.length() >= 3 && (path[2] == '/' || path[2] == '\\')){
114+
return r + path[2];
115+
}
116+
117+
return r;
118+
} else
119+
return "/";
120+
114121
#endif
115122
}
116123

src/windows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ bool fs_win32_is_symlink(std::string_view path)
184184
bool
185185
fs_win32_is_ext_path(std::string_view path)
186186
{
187-
return path.substr(0, 4) == R"(\\?\)" || path.substr(0, 4) == R"(\\.\)";
187+
return path.length() >= 4 && (path.substr(0, 4) == R"(\\?\)" || path.substr(0, 4) == R"(\\.\)");
188188
}
189189

190190

0 commit comments

Comments
 (0)