Commit c15981ee authored by Steve Lhomme's avatar Steve Lhomme Committed by Hugo Beauzée-Luyssen

win32: DeviceLister: always use the wide chars API

The use of FromWide and L'\\' already implied it was the case.
parent a89e384d
Pipeline #5615 passed with stages
in 11 minutes and 52 seconds
...@@ -160,7 +160,6 @@ dnl Specify -lpthread as part of Libs.private, in case of a static build ...@@ -160,7 +160,6 @@ dnl Specify -lpthread as part of Libs.private, in case of a static build
;; ;;
*mingw32* | *cygwin* | *wince* | *mingwce*) *mingw32* | *cygwin* | *wince* | *mingwce*)
CXXFLAGS="${CXXFLAGS} -static-libgcc -static-libstdc++" CXXFLAGS="${CXXFLAGS} -static-libgcc -static-libstdc++"
AC_DEFINE([_UNICODE], [1], [Define to 1 for Unicode (Wide Chars) APIs.])
AC_DEFINE([UNICODE], [1], [Define to 1 for Unicode (Wide Chars) APIs.]) AC_DEFINE([UNICODE], [1], [Define to 1 for Unicode (Wide Chars) APIs.])
AC_DEFINE([_POSIX_C_SOURCE], [200809L], [IEEE Std 1003.1.]) AC_DEFINE([_POSIX_C_SOURCE], [200809L], [IEEE Std 1003.1.])
AC_DEFINE([_BSD_SOURCE], [1], [ISO C, POSIX, and 4.3BSD things.]) AC_DEFINE([_BSD_SOURCE], [1], [ISO C, POSIX, and 4.3BSD things.])
......
...@@ -44,8 +44,8 @@ namespace fs ...@@ -44,8 +44,8 @@ namespace fs
std::vector<std::tuple<std::string, std::string, bool>> DeviceLister::devices() const std::vector<std::tuple<std::string, std::string, bool>> DeviceLister::devices() const
{ {
TCHAR volumeName[MAX_PATH]; wchar_t volumeName[MAX_PATH];
auto handle = FindFirstVolume( volumeName, sizeof(volumeName) ); auto handle = FindFirstVolume( volumeName, sizeof(volumeName)/sizeof(volumeName[0]) );
if ( handle == INVALID_HANDLE_VALUE ) if ( handle == INVALID_HANDLE_VALUE )
{ {
std::stringstream ss; std::stringstream ss;
...@@ -55,7 +55,7 @@ std::vector<std::tuple<std::string, std::string, bool>> DeviceLister::devices() ...@@ -55,7 +55,7 @@ std::vector<std::tuple<std::string, std::string, bool>> DeviceLister::devices()
std::unique_ptr<typename std::remove_pointer<HANDLE>::type, decltype(&FindVolumeClose)> std::unique_ptr<typename std::remove_pointer<HANDLE>::type, decltype(&FindVolumeClose)>
uh( handle, &FindVolumeClose ); uh( handle, &FindVolumeClose );
std::vector<std::tuple<std::string, std::string, bool>> res; std::vector<std::tuple<std::string, std::string, bool>> res;
for ( BOOL success = TRUE; ; success = FindNextVolume( handle, volumeName, sizeof( volumeName ) ) ) for ( BOOL success = TRUE; ; success = FindNextVolume( handle, volumeName, sizeof( volumeName )/sizeof(volumeName[0]) ) )
{ {
if ( success == FALSE ) if ( success == FALSE )
{ {
...@@ -72,8 +72,8 @@ std::vector<std::tuple<std::string, std::string, bool>> DeviceLister::devices() ...@@ -72,8 +72,8 @@ std::vector<std::tuple<std::string, std::string, bool>> DeviceLister::devices()
volumeName[3] != L'\\' || volumeName[lastChar] != L'\\' ) volumeName[3] != L'\\' || volumeName[lastChar] != L'\\' )
continue; continue;
TCHAR buffer[MAX_PATH + 1]; wchar_t buffer[MAX_PATH + 1];
DWORD buffLength = sizeof( buffer ); DWORD buffLength = sizeof( buffer ) / sizeof( wchar_t );
if ( GetVolumePathNamesForVolumeName( volumeName, buffer, buffLength, &buffLength ) == 0 ) if ( GetVolumePathNamesForVolumeName( volumeName, buffer, buffLength, &buffLength ) == 0 )
continue; continue;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <tchar.h>
#include <stdexcept> #include <stdexcept>
#include <system_error> #include <system_error>
...@@ -48,7 +47,7 @@ File::File( const std::string& filePath ) ...@@ -48,7 +47,7 @@ File::File( const std::string& filePath )
: CommonFile( utils::file::toMrl( filePath ) ) : CommonFile( utils::file::toMrl( filePath ) )
{ {
struct _stat s; struct _stat s;
if ( _tstat( charset::ToWide( filePath.c_str() ).get(), &s ) != 0 ) if ( _wstat( charset::ToWide( filePath.c_str() ).get(), &s ) != 0 )
{ {
LOG_ERROR( "Failed to get ", filePath, " stats" ); LOG_ERROR( "Failed to get ", filePath, " stats" );
throw std::system_error( errno, std::generic_category(), "Failed to get stats" ); throw std::system_error( errno, std::generic_category(), "Failed to get stats" );
......
...@@ -89,7 +89,7 @@ std::string toAbsolute( const std::string& path ) ...@@ -89,7 +89,7 @@ std::string toAbsolute( const std::string& path )
} }
return file::toFolderPath( abs ); return file::toFolderPath( abs );
#else #else
TCHAR buff[MAX_PATH]; wchar_t buff[MAX_PATH];
auto wpath = charset::ToWide( path.c_str() ); auto wpath = charset::ToWide( path.c_str() );
if ( GetFullPathName( wpath.get(), MAX_PATH, buff, nullptr ) == 0 ) if ( GetFullPathName( wpath.get(), MAX_PATH, buff, nullptr ) == 0 )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment