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
;;
*mingw32* | *cygwin* | *wince* | *mingwce*)
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([_POSIX_C_SOURCE], [200809L], [IEEE Std 1003.1.])
AC_DEFINE([_BSD_SOURCE], [1], [ISO C, POSIX, and 4.3BSD things.])
......
......@@ -44,8 +44,8 @@ namespace fs
std::vector<std::tuple<std::string, std::string, bool>> DeviceLister::devices() const
{
TCHAR volumeName[MAX_PATH];
auto handle = FindFirstVolume( volumeName, sizeof(volumeName) );
wchar_t volumeName[MAX_PATH];
auto handle = FindFirstVolume( volumeName, sizeof(volumeName)/sizeof(volumeName[0]) );
if ( handle == INVALID_HANDLE_VALUE )
{
std::stringstream ss;
......@@ -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)>
uh( handle, &FindVolumeClose );
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 )
{
......@@ -72,8 +72,8 @@ std::vector<std::tuple<std::string, std::string, bool>> DeviceLister::devices()
volumeName[3] != L'\\' || volumeName[lastChar] != L'\\' )
continue;
TCHAR buffer[MAX_PATH + 1];
DWORD buffLength = sizeof( buffer );
wchar_t buffer[MAX_PATH + 1];
DWORD buffLength = sizeof( buffer ) / sizeof( wchar_t );
if ( GetVolumePathNamesForVolumeName( volumeName, buffer, buffLength, &buffLength ) == 0 )
continue;
......
......@@ -31,7 +31,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <tchar.h>
#include <stdexcept>
#include <system_error>
......@@ -48,7 +47,7 @@ File::File( const std::string& filePath )
: CommonFile( utils::file::toMrl( filePath ) )
{
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" );
throw std::system_error( errno, std::generic_category(), "Failed to get stats" );
......
......@@ -89,7 +89,7 @@ std::string toAbsolute( const std::string& path )
}
return file::toFolderPath( abs );
#else
TCHAR buff[MAX_PATH];
wchar_t buff[MAX_PATH];
auto wpath = charset::ToWide( path.c_str() );
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