From 31a41b795e9ee4876c7e3b9b8c745ed1ec651fd2 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sat, 25 Apr 2015 23:55:15 +0300 Subject: [PATCH] fs::dir::get_first fixed --- Utilities/File.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 96241545de..cb046869aa 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -705,11 +705,27 @@ bool fs::dir::get_first(std::string& name, stat_t& info) WIN32_FIND_DATAW found; m_dd = (intptr_t)FindFirstFileW(m_path.get(), &found); + + if (m_dd == null) + { + return false; + } + + name = ConvertWCharToUTF8(found.cFileName); + + info.is_directory = (found.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; + info.is_writable = (found.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0; + info.size = ((u64)found.nFileSizeHigh << 32) | (u64)found.nFileSizeLow; + info.atime = to_time_t(found.ftLastAccessTime); + info.mtime = to_time_t(found.ftLastWriteTime); + info.ctime = to_time_t(found.ftCreationTime); + + return true; #else m_dd = (intptr_t)::opendir(m_path.get()); -#endif return get_next(name, info); +#endif } bool fs::dir::get_next(std::string& name, stat_t& info)