File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -346,17 +346,30 @@ Filesystem::exists(string_view path) noexcept
346346bool
347347Filesystem::is_directory (string_view path) noexcept
348348{
349+ #ifdef _WIN32
350+ DWORD attr = GetFileAttributesW (
351+ Strutil::utf8_to_utf16wstring (path).c_str ());
352+ return attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY);
353+ #else
349354 error_code ec;
350355 return filesystem::is_directory (u8path (path), ec);
356+ #endif
351357}
352358
353359
354360
355361bool
356362Filesystem::is_regular (string_view path) noexcept
357363{
364+ #ifdef _WIN32
365+ DWORD attr = GetFileAttributesW (
366+ Strutil::utf8_to_utf16wstring (path).c_str ());
367+ return attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY)
368+ && !(attr & FILE_ATTRIBUTE_REPARSE_POINT); // exclude symlinks
369+ #else
358370 error_code ec;
359371 return filesystem::is_regular_file (u8path (path), ec);
372+ #endif
360373}
361374
362375
@@ -774,9 +787,18 @@ Filesystem::last_write_time(string_view path, std::time_t time) noexcept
774787uint64_t
775788Filesystem::file_size (string_view path) noexcept
776789{
790+ #ifdef _WIN32
791+ WIN32_FILE_ATTRIBUTE_DATA data {};
792+ if (!GetFileAttributesExW (Strutil::utf8_to_utf16wstring (path).c_str (),
793+ GetFileExInfoStandard, &data))
794+ return 0 ;
795+ return (static_cast <uint64_t >(data.nFileSizeHigh ) << 32 )
796+ | static_cast <uint64_t >(data.nFileSizeLow );
797+ #else
777798 error_code ec;
778799 uint64_t sz = filesystem::file_size (u8path (path), ec);
779800 return ec ? 0 : sz;
801+ #endif
780802}
781803
782804
You can’t perform that action at this time.
0 commit comments