aboutsummaryrefslogtreecommitdiff
path: root/src/common/windows/http_upload.cc
diff options
context:
space:
mode:
authorted.mielczarek@gmail.com <ted.mielczarek@gmail.com>2014-11-03 17:05:39 +0000
committerted.mielczarek@gmail.com <ted.mielczarek@gmail.com>2014-11-03 17:05:39 +0000
commitc971cf439cec3d412e297199db2416523c1a889d (patch)
tree491b9867f0696cb5007d627c82fc183085effc5a /src/common/windows/http_upload.cc
parentIntroduce microdump writer class. (diff)
downloadbreakpad-c971cf439cec3d412e297199db2416523c1a889d.tar.xz
Fix Windows client compilation on mingw.
A=Jacek Caban <jacek@codeweavers.com>, R=ted at http://breakpad.appspot.com/548002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1399 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/windows/http_upload.cc')
-rw-r--r--src/common/windows/http_upload.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/common/windows/http_upload.cc b/src/common/windows/http_upload.cc
index 838185b7..ba04d7d0 100644
--- a/src/common/windows/http_upload.cc
+++ b/src/common/windows/http_upload.cc
@@ -327,11 +327,13 @@ bool HTTPUpload::GetFileContents(const wstring &filename,
// wchar_t* filename, so use _wfopen directly in that case. For VC8 and
// later, _wfopen has been deprecated in favor of _wfopen_s, which does
// not exist in earlier versions, so let the ifstream open the file itself.
-#if _MSC_VER >= 1400 // MSVC 2005/8
+ // GCC doesn't support wide file name and opening on FILE* requires ugly
+ // hacks, so fallback to multi byte file.
+#ifdef _MSC_VER
ifstream file;
file.open(filename.c_str(), ios::binary);
-#else // _MSC_VER >= 1400
- ifstream file(_wfopen(filename.c_str(), L"rb"));
+#else // GCC
+ ifstream file(WideToMBCP(filename, CP_ACP).c_str(), ios::binary);
#endif // _MSC_VER >= 1400
if (file.is_open()) {
file.seekg(0, ios::end);
@@ -375,13 +377,13 @@ wstring HTTPUpload::UTF8ToWide(const string &utf8) {
}
// static
-string HTTPUpload::WideToUTF8(const wstring &wide) {
+string HTTPUpload::WideToMBCP(const wstring &wide, unsigned int cp) {
if (wide.length() == 0) {
return string();
}
// compute the length of the buffer we'll need
- int charcount = WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1,
+ int charcount = WideCharToMultiByte(cp, 0, wide.c_str(), -1,
NULL, 0, NULL, NULL);
if (charcount == 0) {
return string();
@@ -389,7 +391,7 @@ string HTTPUpload::WideToUTF8(const wstring &wide) {
// convert
char *buf = new char[charcount];
- WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, buf, charcount,
+ WideCharToMultiByte(cp, 0, wide.c_str(), -1, buf, charcount,
NULL, NULL);
string result(buf);