static
void
-count (boost::filesystem::path dir, uint64_t& total_bytes)
+count (std::vector<boost::filesystem::path> dirs, uint64_t& total_bytes)
{
- dir = dcp::fix_long_path (dir);
-
using namespace boost::filesystem;
- for (auto i: directory_iterator(dir)) {
- if (is_directory(i)) {
- count (i, total_bytes);
- } else {
- total_bytes += file_size (i);
+
+ for (auto dir: dirs) {
+ dir = dcp::fix_long_path(dir);
+ for (auto path: directory_iterator(dir)) {
+ if (is_directory(path)) {
+ count({path}, total_bytes);
+ } else {
+ total_bytes += file_size(path);
+ }
}
}
}
++progress_count;
if ((progress_count % progress_frequency) == 0 && nanomsg) {
- nanomsg->send(String::compose(DISK_WRITER_COPY_PROGRESS "\n%1\n", (1 - float(total_remaining) / total)), SHORT_TIMEOUT);
+ DiskWriterBackEndResponse::copy_progress(1 - float(total_remaining) / total).write_to_nanomsg(*nanomsg, SHORT_TIMEOUT);
}
}
remaining -= this_time;
total_remaining -= this_time;
if (nanomsg) {
- nanomsg->send(String::compose(DISK_WRITER_VERIFY_PROGRESS "\n%1\n", (1 - float(total_remaining) / total)), SHORT_TIMEOUT);
+ DiskWriterBackEndResponse::verify_progress(1 - float(total_remaining) / total).write_to_nanomsg(*nanomsg, SHORT_TIMEOUT);
}
}
format_progress (void* context, float progress)
{
if (context) {
- reinterpret_cast<Nanomsg*>(context)->send(String::compose(DISK_WRITER_FORMAT_PROGRESS "\n%1\n", progress), SHORT_TIMEOUT);
+ DiskWriterBackEndResponse::format_progress(progress).write_to_nanomsg(*reinterpret_cast<Nanomsg*>(context), SHORT_TIMEOUT);
}
}
void
#ifdef DCPOMATIC_WINDOWS
-dcpomatic::write (boost::filesystem::path dcp_path, string device, string, Nanomsg* nanomsg)
+dcpomatic::write (vector<boost::filesystem::path> dcp_paths, string device, string, Nanomsg* nanomsg)
#else
-dcpomatic::write (boost::filesystem::path dcp_path, string device, string posix_partition, Nanomsg* nanomsg)
+dcpomatic::write (vector<boost::filesystem::path> dcp_paths, string device, string posix_partition, Nanomsg* nanomsg)
#endif
try
{
LOG_DISK_NC ("Mounted device");
uint64_t total_bytes = 0;
- count (dcp_path, total_bytes);
+ count (dcp_paths, total_bytes);
uint64_t total_remaining = total_bytes;
vector<CopiedFile> copied_files;
- copy (dcp_path, "/mp", total_remaining, total_bytes, copied_files, nanomsg);
+ for (auto dcp_path: dcp_paths) {
+ copy (dcp_path, "/mp", total_remaining, total_bytes, copied_files, nanomsg);
+ }
/* Unmount and re-mount to make sure the write has finished */
r = ext4_umount("/mp/");
}
ext4_device_unregister("ext4_fs");
- if (nanomsg && !nanomsg->send(DISK_WRITER_OK "\n", LONG_TIMEOUT)) {
+ if (nanomsg && !DiskWriterBackEndResponse::ok().write_to_nanomsg(*nanomsg, LONG_TIMEOUT)) {
throw CommunicationFailedError ();
}
} catch (CopyError& e) {
LOG_DISK("CopyError (from write): %1 %2", e.message(), e.number().get_value_or(0));
if (nanomsg) {
- nanomsg->send(String::compose(DISK_WRITER_ERROR "\n%1\n%2\n", e.message(), e.number().get_value_or(0)), LONG_TIMEOUT);
+ DiskWriterBackEndResponse::error(e.message(), e.number().get_value_or(0)).write_to_nanomsg(*nanomsg, LONG_TIMEOUT);
}
} catch (VerifyError& e) {
LOG_DISK("VerifyError (from write): %1 %2", e.message(), e.number());
if (nanomsg) {
- nanomsg->send(String::compose(DISK_WRITER_ERROR "\n%1\n%2\n", e.message(), e.number()), LONG_TIMEOUT);
+ DiskWriterBackEndResponse::error(e.message(), e.number()).write_to_nanomsg(*nanomsg, LONG_TIMEOUT);
}
} catch (exception& e) {
LOG_DISK("Exception (from write): %1", e.what());
if (nanomsg) {
- nanomsg->send(String::compose(DISK_WRITER_ERROR "\n%1\n0\n", e.what()), LONG_TIMEOUT);
+ DiskWriterBackEndResponse::error(e.what(), 0).write_to_nanomsg(*nanomsg, LONG_TIMEOUT);
}
}