From fb3f1624cfe55e4954128c7fb8d4b02ea4a548ab Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 16 Aug 2005 19:06:25 +0000 Subject: [PATCH] better unicode support on windows --- src/storage.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/storage.cpp b/src/storage.cpp index 9fb4d7599..94c4e93ea 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -73,6 +73,8 @@ POSSIBILITY OF SUCH DAMAGE. #if defined(WIN32) && defined(UNICODE) #include +#include +#include "libtorrent/utf8.hpp" namespace { @@ -120,12 +122,12 @@ namespace std::time_t last_write_time_win( const path & ph ) { // Works for both Windows and POSIX - struct stat path_stat; + struct _stat path_stat; std::wstring wph(safe_convert(ph.native_file_string())); - if ( ::wstat( wph.c_str(), &path_stat ) != 0 ) + if ( ::_wstat( wph.c_str(), &path_stat ) != 0 ) boost::throw_exception( filesystem_error( "boost::filesystem::last_write_time", - ph, fs::detail::system_error_code() ) ); + ph, detail::system_error_code() ) ); return path_stat.st_mtime; } @@ -137,7 +139,7 @@ namespace if ( !::MoveFile( wold_path.c_str(), wnew_path.c_str() ) ) boost::throw_exception( filesystem_error( "boost::filesystem::rename", - old_path, new_path, fs::detail::system_error_code() ) ); + old_path, new_path, detail::system_error_code() ) ); } } // anonymous namespace @@ -462,7 +464,7 @@ namespace libtorrent { CreateDirectory(wsave_path.c_str(), 0); } - else if ((GetFileAttributes(wsave_path) & FILE_ATTRIBUTE_DIRECTORY) == 0) + else if ((GetFileAttributes(wsave_path.c_str()) & FILE_ATTRIBUTE_DIRECTORY) == 0) { return false; } @@ -523,7 +525,7 @@ namespace libtorrent std::random_shuffle(pieces.begin(), pieces.end()); std::random_shuffle(targets.begin(), targets.end()); - for (int i = 0; i < std::max(num_pieces / 50, 1); ++i) + for (int i = 0; i < (std::max)(num_pieces / 50, 1); ++i) { const int slot_index = targets[i]; const int piece_index = pieces[i];