diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-01-27 00:43:05 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-01-29 22:49:56 +0100 |
| commit | 7bce98ec4c05081569cb66b68523e1466058ea76 (patch) | |
| tree | 8d4847ff0c6eb5c5f5c0a6ad63126d7b21c37125 /src/tools | |
| parent | ce603965fbf2021befb1d8c18fe96c677843eba5 (diff) | |
Add DiskWriterBackendResponse::write_to_nanomsg() and use it
everywhere. In the process, use raw_convert() on both ends
to avoid any locale-based problems with floating point number
separators.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/dcpomatic_disk_writer.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/tools/dcpomatic_disk_writer.cc b/src/tools/dcpomatic_disk_writer.cc index ef3bf2f77..5a10d75cb 100644 --- a/src/tools/dcpomatic_disk_writer.cc +++ b/src/tools/dcpomatic_disk_writer.cc @@ -164,7 +164,7 @@ try if (*s == DISK_WRITER_QUIT) { exit (EXIT_SUCCESS); } else if (*s == DISK_WRITER_PING) { - nanomsg->send(DISK_WRITER_PONG "\n", LONG_TIMEOUT); + DiskWriterBackEndResponse::pong().write_to_nanomsg(*nanomsg, LONG_TIMEOUT); } else if (*s == DISK_WRITER_UNMOUNT) { auto xml_head = nanomsg->receive (LONG_TIMEOUT); auto xml_body = nanomsg->receive (LONG_TIMEOUT); @@ -179,9 +179,9 @@ try bool const success = Drive(xml).unmount(); bool sent_reply = false; if (success) { - sent_reply = nanomsg->send(DISK_WRITER_OK "\n", LONG_TIMEOUT); + sent_reply = DiskWriterBackEndResponse::ok().write_to_nanomsg(*nanomsg, LONG_TIMEOUT); } else { - sent_reply = nanomsg->send(DISK_WRITER_ERROR "\nCould not unmount drive\n1\n", LONG_TIMEOUT); + sent_reply = DiskWriterBackEndResponse::error("Could not unmount drive", 1).write_to_nanomsg(*nanomsg, LONG_TIMEOUT); } if (!sent_reply) { LOG_DISK_NC("CommunicationFailedError in unmount_finished"); @@ -189,7 +189,7 @@ try } }, []() { - if (!nanomsg->send(DISK_WRITER_ERROR "\nCould not get permission to unmount drive\n1\n", LONG_TIMEOUT)) { + if (!DiskWriterBackEndResponse::error("Could not get permission to unmount drive", 1).write_to_nanomsg(*nanomsg, LONG_TIMEOUT)) { LOG_DISK_NC("CommunicationFailedError in unmount_finished"); throw CommunicationFailedError (); } @@ -221,21 +221,21 @@ try #ifdef DCPOMATIC_OSX if (!starts_with(device, "/dev/disk")) { LOG_DISK ("Will not write to %1", device); - nanomsg->send(DISK_WRITER_ERROR "\nRefusing to write to this drive\n1\n", LONG_TIMEOUT); + DiskWriterBackEndResponse::error("Refusing to write to this drive", 1).write_to_nanomsg(*nanomsg, LONG_TIMEOUT); return true; } #endif #ifdef DCPOMATIC_LINUX if (!starts_with(device, "/dev/sd") && !starts_with(device, "/dev/hd")) { LOG_DISK ("Will not write to %1", device); - nanomsg->send(DISK_WRITER_ERROR "\nRefusing to write to this drive\n1\n", LONG_TIMEOUT); + DiskWriterBackEndResponse::error("Refusing to write to this drive", 1).write_to_nanomsg(*nanomsg, LONG_TIMEOUT); return true; } #endif #ifdef DCPOMATIC_WINDOWS if (!starts_with(device, "\\\\.\\PHYSICALDRIVE")) { LOG_DISK ("Will not write to %1", device); - nanomsg->send(DISK_WRITER_ERROR "\nRefusing to write to this drive\n1\n", LONG_TIMEOUT); + DiskWriterBackEndResponse::error("Refusing to write to this drive", 1).write_to_nanomsg(*nanomsg, LONG_TIMEOUT); return true; } #endif @@ -251,12 +251,12 @@ try if (!on_drive_list) { LOG_DISK ("Will not write to %1 as it's not recognised as a drive", device); - nanomsg->send(DISK_WRITER_ERROR "\nRefusing to write to this drive\n1\n", LONG_TIMEOUT); + DiskWriterBackEndResponse::error("Refusing to write to this drive", 1).write_to_nanomsg(*nanomsg, LONG_TIMEOUT); return true; } if (mounted) { LOG_DISK ("Will not write to %1 as it's mounted", device); - nanomsg->send(DISK_WRITER_ERROR "\nRefusing to write to this drive\n1\n", LONG_TIMEOUT); + DiskWriterBackEndResponse::error("Refusing to write to this drive", 1).write_to_nanomsg(*nanomsg, LONG_TIMEOUT); return true; } @@ -286,7 +286,7 @@ try }, []() { if (nanomsg) { - nanomsg->send(DISK_WRITER_ERROR "\nCould not obtain authorization to write to the drive\n1\n", LONG_TIMEOUT); + DiskWriterBackEndResponse::error("Could not obtain authorization to write to the drive", 1).write_to_nanomsg(*nanomsg, LONG_TIMEOUT); } }); } |
