diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2019-11-22 12:20:16 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@chromium.org> | 2019-11-22 18:29:21 +0000 |
commit | 1f1d950d6a4b1cb375ebfbc4e40f9517c592b94f (patch) | |
tree | 1a30bd2bb69eec75116e694d8e618e41fd670602 /src/common | |
parent | mac processor: Add mapping for EXC_BAD_ACCESS/KERN_CODESIGN_ERROR (diff) | |
download | breakpad-1f1d950d6a4b1cb375ebfbc4e40f9517c592b94f.tar.xz |
Fix compilation of http_upload.cc with Windows gcc
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<char>*)’:
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 <vapier@chromium.org>
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/windows/http_upload.cc | 68 |
1 files changed, 34 insertions, 34 deletions
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<char> *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<char>::size_type - std::vector<char>::size_type vector_size = - static_cast<std::vector<char>::size_type>(length); - if (static_cast<std::streamoff>(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<char> *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<char>::size_type + std::vector<char>::size_type vector_size = + static_cast<std::vector<char>::size_type>(length); + if (static_cast<std::streamoff>(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<wstring, wstring> ¶meters) { for (map<wstring, wstring>::const_iterator pos = parameters.begin(); pos != parameters.end(); ++pos) { |