From 2c4d38d394fd2c89fba5962b0afde4eec081be30 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sat, 20 Apr 2013 02:55:15 +0200 Subject: [PATCH] FIRE-9825; Windows does not use UTF8 but UTF16 filenames. Hence all filenames on Windows to UTF16 and open files using the wide character string. --- indra/llcommon/llfile.cpp | 46 ++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index bc615ed39e..4ec999c8e4 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -853,7 +853,12 @@ llifstream::llifstream(const std::string& _Filename, #if LL_WINDOWS std::istream(&_M_filebuf) { - if (_M_filebuf.open(_Filename.c_str(), _Mode | ios_base::in) == 0) + // Need to convert to UTF16 for Win, Windows API does not use UTF8 + + // if (_M_filebuf.open(_Filename.c_str(), _Mode | ios_base::in) == 0) + llutf16string wideName = utf8str_to_utf16str( _Filename ); + if (_M_filebuf.open(wideName.c_str(), _Mode | ios_base::in) == 0) + // { _Myios::setstate(ios_base::failbit); } @@ -872,7 +877,12 @@ llifstream::llifstream(const char* _Filename, #if LL_WINDOWS std::istream(&_M_filebuf) { - if (_M_filebuf.open(_Filename, _Mode | ios_base::in) == 0) + // Need to convert to UTF16 for Win, Windows API does not use UTF8 + + // if (_M_filebuf.open(_Filename, _Mode | ios_base::in) == 0) + llutf16string wideName = utf8str_to_utf16str( _Filename ); + if (_M_filebuf.open(wideName.c_str(), _Mode | ios_base::in) == 0) + // { _Myios::setstate(ios_base::failbit); } @@ -917,8 +927,14 @@ bool llifstream::is_open() const void llifstream::open(const char* _Filename, ios_base::openmode _Mode) { // open a C stream with specified mode - if (_M_filebuf.open(_Filename, _Mode | ios_base::in) == 0) + + // Need to convert to UTF16 for Win, Windows API does not use UTF8 + // if (_M_filebuf.open(_Filename, _Mode | ios_base::in) == 0) + // + #if LL_WINDOWS + llutf16string wideName = utf8str_to_utf16str( _Filename ); + if (_M_filebuf.open( wideName.c_str(), _Mode | ios_base::in) == 0) { _Myios::setstate(ios_base::failbit); } @@ -927,6 +943,7 @@ void llifstream::open(const char* _Filename, ios_base::openmode _Mode) _Myios::clear(); } #else + if (_M_filebuf.open(_Filename, _Mode | ios_base::in) == 0) { this->setstate(ios_base::failbit); } @@ -969,7 +986,12 @@ llofstream::llofstream(const std::string& _Filename, #if LL_WINDOWS std::ostream(&_M_filebuf) { - if (_M_filebuf.open(_Filename.c_str(), _Mode | ios_base::out) == 0) + // Need to convert to UTF16 for Win, Windows API does not use UTF8 + + // if (_M_filebuf.open(_Filename.c_str(), _Mode | ios_base::out) == 0) + llutf16string wideName = utf8str_to_utf16str( _Filename ); + if (_M_filebuf.open( wideName.c_str(), _Mode | ios_base::out) == 0) + // { _Myios::setstate(ios_base::failbit); } @@ -988,7 +1010,12 @@ llofstream::llofstream(const char* _Filename, #if LL_WINDOWS std::ostream(&_M_filebuf) { - if (_M_filebuf.open(_Filename, _Mode | ios_base::out) == 0) + // Need to convert to UTF16 for Win, Windows API does not use UTF8 + + // if (_M_filebuf.open(_Filename, _Mode | ios_base::out) == 0) + llutf16string wideName = utf8str_to_utf16str( _Filename ); + if (_M_filebuf.open( wideName.c_str(), _Mode | ios_base::out) == 0) + // { _Myios::setstate(ios_base::failbit); } @@ -1032,8 +1059,14 @@ bool llofstream::is_open() const void llofstream::open(const char* _Filename, ios_base::openmode _Mode) { // open a C stream with specified mode - if (_M_filebuf.open(_Filename, _Mode | ios_base::out) == 0) + + // Need to convert to UTF16 for Win, Windows API does not use UTF8 + // if (_M_filebuf.open(_Filename, _Mode | ios_base::out) == 0) + // + #if LL_WINDOWS + llutf16string wideName = utf8str_to_utf16str( _Filename ); + if (_M_filebuf.open( wideName.c_str(), _Mode | ios_base::out) == 0) { _Myios::setstate(ios_base::failbit); } @@ -1042,6 +1075,7 @@ void llofstream::open(const char* _Filename, ios_base::openmode _Mode) _Myios::clear(); } #else + if (_M_filebuf.open(_Filename, _Mode | ios_base::out) == 0) { this->setstate(ios_base::failbit); }