X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcurl_uploader.cc;h=6fe7aba145c40ecfa2fd91f2ae035dee0d6f0a5b;hb=ff639b3cf30afcc097bfd21d39c8d15f466cadd6;hp=60835bea716cc6eab0e696f738dc95550ad06863;hpb=689fa55d1529ad88449ca464e9107c4dcc54d1cb;p=dcpomatic.git diff --git a/src/lib/curl_uploader.cc b/src/lib/curl_uploader.cc index 60835bea7..6fe7aba14 100644 --- a/src/lib/curl_uploader.cc +++ b/src/lib/curl_uploader.cc @@ -24,6 +24,7 @@ #include "config.h" #include "cross.h" #include "compose.hpp" +#include "dcpomatic_assert.h" #include #include "i18n.h" @@ -62,9 +63,6 @@ CurlUploader::CurlUploader (function set_status, functiontms_ip(), Config::instance()->tms_path(), to.generic_string ()).c_str () ); - _file = fopen_boost (from, "rb"); - if (!_file) { + dcp::File file(from, "rb"); + if (!file) { throw NetworkError (String::compose (_("Could not open %1 to send"), from)); } + _file = file.get(); _transferred = &transferred; _total_size = total_size; @@ -97,15 +96,15 @@ CurlUploader::upload_file (boost::filesystem::path from, boost::filesystem::path throw NetworkError (String::compose (_("Could not write to remote file (%1)"), curl_easy_strerror (r))); } - fclose (_file); - _file = 0; + _file = nullptr; } size_t CurlUploader::read_callback (void* ptr, size_t size, size_t nmemb) { - size_t const r = fread (ptr, size, nmemb, _file); + DCPOMATIC_ASSERT (_file); + size_t const r = fread(ptr, size, nmemb, _file); *_transferred += size * nmemb; if (_total_size > 0) {