From 43e201ee92d814c63f75718b516417855a5ac979 Mon Sep 17 00:00:00 2001 From: Bing Liu Date: Sat, 13 Jan 2024 16:37:33 +0800 Subject: [PATCH] Also use _stat() on Windows to be more UTF8 friendly --- include/spdlog/details/os-inl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index d15b22e4..95f831de 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -177,12 +177,12 @@ SPDLOG_INLINE int rename(const filename_t &filename1, const filename_t &filename // Return true if path exists (file or directory) SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT { #ifdef _WIN32 + struct _stat64i32 buffer; #ifdef SPDLOG_WCHAR_FILENAMES - auto attribs = ::GetFileAttributesW(filename.c_str()); + return (::_wstat64i32(filename.c_str(), &buffer) == 0); #else - auto attribs = ::GetFileAttributesA(filename.c_str()); + return (::_stat64i32(filename.c_str(), &buffer) == 0); #endif - return attribs != INVALID_FILE_ATTRIBUTES; #else // common linux/unix all have the stat system call struct stat buffer; return (::stat(filename.c_str(), &buffer) == 0);