From 3056622861e4cd24e9c2b1658d77ec00353a4868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Fri, 21 Jun 2019 01:23:59 -0300 Subject: [PATCH] Fixed FileSystem::getDiskFreeSpace. --HG-- branch : dev --- src/eepp/system/filesystem.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/eepp/system/filesystem.cpp b/src/eepp/system/filesystem.cpp index 260f17124..5650473b4 100644 --- a/src/eepp/system/filesystem.cpp +++ b/src/eepp/system/filesystem.cpp @@ -258,16 +258,16 @@ std::vector FileSystem::filesGetInPath( const String& path, const bool& #ifdef EE_COMPILER_MSVC #ifdef UNICODE - String mPath( path ); + String widePath( path ); - if ( mPath[ mPath.size() - 1 ] == '/' || mPath[ mPath.size() - 1 ] == '\\' ) { - mPath += "*"; + if ( widePath[ widePath.size() - 1 ] == '/' || widePath[ widePath.size() - 1 ] == '\\' ) { + widePath += "*"; } else { - mPath += "\\*"; + widePath += "\\*"; } WIN32_FIND_DATA findFileData; - HANDLE hFind = FindFirstFile( (LPCWSTR)mPath.toWideString().c_str(), &findFileData ); + HANDLE hFind = FindFirstFile( widePath.toWideString().c_str(), &findFileData ); if( hFind != INVALID_HANDLE_VALUE ) { String tmpstr( findFileData.cFileName ); @@ -380,16 +380,16 @@ std::vector FileSystem::filesGetInPath( const std::string& path, co #ifdef EE_COMPILER_MSVC #ifdef UNICODE - String mPath( String::fromUtf8( path ) ); + String widePath( path ); - if ( mPath[ mPath.size() - 1 ] == '/' || mPath[ mPath.size() - 1 ] == '\\' ) { - mPath += "*"; + if ( widePath[ widePath.size() - 1 ] == '/' || widePath[ widePath.size() - 1 ] == '\\' ) { + widePath += "*"; } else { - mPath += "\\*"; + widePath += "\\*"; } WIN32_FIND_DATA findFileData; - HANDLE hFind = FindFirstFile( (LPCWSTR)mPath.toWideString().c_str(), &findFileData ); + HANDLE hFind = FindFirstFile( widePath.toWideString().c_str(), &findFileData ); if( hFind != INVALID_HANDLE_VALUE ) { String tmpstr( findFileData.cFileName ); @@ -449,13 +449,11 @@ std::vector FileSystem::filesGetInPath( const std::string& path, co closedir(dp); #endif - if ( sortByName == true ) - { + if ( sortByName == true ) { std::sort( files.begin(), files.end() ); } - if ( foldersFirst == true ) - { + if ( foldersFirst == true ) { String fpath( path ); if ( fpath[ fpath.size() - 1 ] != '/' && fpath[ fpath.size() - 1 ] != '\\' ) @@ -567,7 +565,7 @@ Int64 FileSystem::getDiskFreeSpace(const std::string& path) { Int64 TotalBytes; Int64 FreeBytes; #ifdef UNICODE - GetDiskFreeSpaceEx((LPCWSTR)path.c_str(),(PULARGE_INTEGER) &AvailableBytes, + GetDiskFreeSpaceEx( String::fromUtf8( path.c_str() ).toWideString().c_str(),(PULARGE_INTEGER) &AvailableBytes, #else GetDiskFreeSpaceEx(path.c_str(),(PULARGE_INTEGER) &AvailableBytes, #endif