From db44381bbce746a35e1a5a0eaf6303a0adb37781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 23 Apr 2016 11:18:09 -0700 Subject: [PATCH] Fixed MSVC stat issue. --- include/bx/os.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/include/bx/os.h b/include/bx/os.h index def60c6..9794baf 100644 --- a/include/bx/os.h +++ b/include/bx/os.h @@ -294,7 +294,25 @@ namespace bx _fileInfo.m_size = 0; _fileInfo.m_type = FileInfo::Count; - struct stat st; +#if BX_COMPILER_MSVC + struct ::_stat64 st; + int32_t result = ::_stat64(_filePath, &st); + + if (0 != result) + { + return false; + } + + if (0 != (st.st_mode & _S_IFREG) ) + { + _fileInfo.m_type = FileInfo::Regular; + } + else if (0 != (st.st_mode & _S_IFDIR) ) + { + _fileInfo.m_type = FileInfo::Directory; + } +#else + struct ::stat st; int32_t result = ::stat(_filePath, &st); if (0 != result) { @@ -309,6 +327,7 @@ namespace bx { _fileInfo.m_type = FileInfo::Directory; } +#endif // BX_COMPILER_MSVC _fileInfo.m_size = st.st_size;