From 1f1d950d6a4b1cb375ebfbc4e40f9517c592b94f Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Fri, 22 Nov 2019 12:20:16 +0000 Subject: Fix compilation of http_upload.cc with Windows gcc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix compilation of http_upload.cc with Windows gcc after 548ca6e3, by moving the definition of GetFileContents(), so it comes after the definition of WideToMBCP(), which it uses (under !_MSC_VER). common/windows/http_upload.cc: In function ‘bool {anonymous}::GetFileContents(const wstring&, std::vector*)’: common/windows/http_upload.cc:80:19: error: ‘WideToMBCP’ was not declared in this scope Change-Id: I1646b39263e97bbf3bd8cb1ae209be238023110f Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1928929 Reviewed-by: Mike Frysinger --- src/common/windows/http_upload.cc | 68 +++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src/common') diff --git a/src/common/windows/http_upload.cc b/src/common/windows/http_upload.cc index 94789792..b0cc9078 100644 --- a/src/common/windows/http_upload.cc +++ b/src/common/windows/http_upload.cc @@ -65,40 +65,6 @@ namespace { HINTERNET handle_; }; - bool GetFileContents(const wstring &filename, vector *contents) { - bool rv = false; - // The "open" method on pre-MSVC8 ifstream implementations doesn't accept a - // 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. - // 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 // GCC - ifstream file(WideToMBCP(filename, CP_ACP).c_str(), ios::binary); -#endif // _MSC_VER >= 1400 - if (file.is_open()) { - file.seekg(0, ios::end); - std::streamoff length = file.tellg(); - // Check for loss of data when converting lenght from std::streamoff into - // std::vector::size_type - std::vector::size_type vector_size = - static_cast::size_type>(length); - if (static_cast(vector_size) == length) { - contents->resize(vector_size); - if (length != 0) { - file.seekg(0, ios::beg); - file.read(&((*contents)[0]), length); - } - rv = true; - } - file.close(); - } - return rv; - } - wstring UTF8ToWide(const string &utf8) { if (utf8.length() == 0) { return wstring(); @@ -141,6 +107,40 @@ namespace { return result; } + bool GetFileContents(const wstring &filename, vector *contents) { + bool rv = false; + // The "open" method on pre-MSVC8 ifstream implementations doesn't accept a + // 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. + // 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 // GCC + ifstream file(WideToMBCP(filename, CP_ACP).c_str(), ios::binary); +#endif // _MSC_VER >= 1400 + if (file.is_open()) { + file.seekg(0, ios::end); + std::streamoff length = file.tellg(); + // Check for loss of data when converting lenght from std::streamoff into + // std::vector::size_type + std::vector::size_type vector_size = + static_cast::size_type>(length); + if (static_cast(vector_size) == length) { + contents->resize(vector_size); + if (length != 0) { + file.seekg(0, ios::beg); + file.read(&((*contents)[0]), length); + } + rv = true; + } + file.close(); + } + return rv; + } + bool CheckParameters(const map ¶meters) { for (map::const_iterator pos = parameters.begin(); pos != parameters.end(); ++pos) { -- cgit v1.2.1