Skip to content

Commit 459508d

Browse files
committed
Speedup to detect the existence of files on Windows
Signed-off-by: Jackson Sun <[email protected]>
1 parent fd5ac81 commit 459508d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/libutil/filesystem.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,15 @@ Filesystem::path_is_absolute(string_view path, bool dot_is_absolute)
330330
bool
331331
Filesystem::exists(string_view path) noexcept
332332
{
333+
#ifdef _WIN32
334+
// filesystem::exists is slow on Windows for network paths, so use the
335+
// WinAPI directly
336+
return INVALID_FILE_ATTRIBUTES != GetFileAttributesW(Strutil::utf8_to_utf16wstring(path).c_str());
337+
#else
333338
error_code ec;
334339
return filesystem::exists(u8path(path), ec);
340+
#endif
341+
335342
}
336343

337344

0 commit comments

Comments
 (0)