From 7cf39227076fbb04fd9b99d7313b8d265e34c47c Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 21 Jun 2018 11:41:08 +0200 Subject: [PATCH] Http: Fix nowide fstream usage --- xs/src/slic3r/Utils/Http.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xs/src/slic3r/Utils/Http.cpp b/xs/src/slic3r/Utils/Http.cpp index 7c4126633..47021d39f 100644 --- a/xs/src/slic3r/Utils/Http.cpp +++ b/xs/src/slic3r/Utils/Http.cpp @@ -41,7 +41,7 @@ struct Http::priv std::string buffer; // Used for storing file streams added as multipart form parts // Using a deque here because unlike vector it doesn't ivalidate pointers on insertion - std::deque form_files; + std::deque form_files; size_t limit; bool cancel; @@ -168,19 +168,18 @@ void Http::priv::form_add_file(const char *name, const fs::path &path, const cha filename = path.string().c_str(); } - fs::ifstream stream(path, std::ios::in | std::ios::binary); + form_files.emplace_back(path, std::ios::in | std::ios::binary); + auto &stream = form_files.back(); stream.seekg(0, std::ios::end); size_t size = stream.tellg(); stream.seekg(0); - form_files.push_back(std::move(stream)); - auto stream_ptr = &form_files.back(); if (filename != nullptr) { ::curl_formadd(&form, &form_end, CURLFORM_COPYNAME, name, CURLFORM_FILENAME, filename, CURLFORM_CONTENTTYPE, "application/octet-stream", - CURLFORM_STREAM, static_cast(stream_ptr), + CURLFORM_STREAM, static_cast(&stream), CURLFORM_CONTENTSLENGTH, static_cast(size), CURLFORM_END );