diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-04-16 22:20:54 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-05 23:38:41 +0200 |
| commit | 8a8c977c12fc65f1f50ea05099387e0fc8840e7d (patch) | |
| tree | 2d2c8663652939d643779d1ab1c18a12813fcbd2 /src/lib/curl_uploader.cc | |
| parent | efe153ab23b54cdbf28c653f2ccb0f25ca6bd015 (diff) | |
Use dcp::File in DCP-o-matic (#2231).
Diffstat (limited to 'src/lib/curl_uploader.cc')
| -rw-r--r-- | src/lib/curl_uploader.cc | 15 |
1 files changed, 7 insertions, 8 deletions
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 <iostream> #include "i18n.h" @@ -62,9 +63,6 @@ CurlUploader::CurlUploader (function<void (string)> set_status, function<void (f CurlUploader::~CurlUploader () { - if (_file) { - fclose (_file); - } curl_easy_cleanup (_curl); } @@ -85,10 +83,11 @@ CurlUploader::upload_file (boost::filesystem::path from, boost::filesystem::path String::compose ("ftp://%1/%2/%3", Config::instance()->tms_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) { |
