aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/windows/http_upload.cc13
-rw-r--r--src/common/windows/http_upload.h2
2 files changed, 7 insertions, 8 deletions
diff --git a/src/common/windows/http_upload.cc b/src/common/windows/http_upload.cc
index a6879799..ddf61f7f 100644
--- a/src/common/windows/http_upload.cc
+++ b/src/common/windows/http_upload.cc
@@ -274,8 +274,7 @@ bool HTTPUpload::GenerateRequestBody(const map<wstring, wstring> &parameters,
const wstring &boundary,
string *request_body) {
vector<char> contents;
- GetFileContents(upload_file, &contents);
- if (contents.empty()) {
+ if (!GetFileContents(upload_file, &contents)) {
return false;
}
@@ -322,7 +321,7 @@ bool HTTPUpload::GenerateRequestBody(const map<wstring, wstring> &parameters,
}
// static
-void HTTPUpload::GetFileContents(const wstring &filename,
+bool HTTPUpload::GetFileContents(const wstring &filename,
vector<char> *contents) {
// 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
@@ -339,13 +338,13 @@ void HTTPUpload::GetFileContents(const wstring &filename,
std::streamoff length = file.tellg();
contents->resize(length);
if (length != 0) {
- file.seekg(0, ios::beg);
- file.read(&((*contents)[0]), length);
+ file.seekg(0, ios::beg);
+ file.read(&((*contents)[0]), length);
}
file.close();
- } else {
- contents->clear();
+ return true;
}
+ return false;
}
// static
diff --git a/src/common/windows/http_upload.h b/src/common/windows/http_upload.h
index f7c69f16..8a17aab1 100644
--- a/src/common/windows/http_upload.h
+++ b/src/common/windows/http_upload.h
@@ -98,7 +98,7 @@ class HTTPUpload {
string *request_body);
// Fills the supplied vector with the contents of filename.
- static void GetFileContents(const wstring &filename, vector<char> *contents);
+ static bool GetFileContents(const wstring &filename, vector<char> *contents);
// Converts a UTF8 string to UTF16.
static wstring UTF8ToWide(const string &utf8);