summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-04-22 00:04:57 +0200
committerCarl Hetherington <cth@carlh.net>2021-04-22 15:42:11 +0200
commitb2c1eb46888c3a606e751c037b6482306a461d5f (patch)
tree1605871edb6e21b295693734c8cdcc0363afa682
parent4dab2ee8e05acdd56b39bb6edd4e80f795d7e0d9 (diff)
C++11 tidying.
-rw-r--r--src/tools/dcpomatic_disk_writer.cc25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/tools/dcpomatic_disk_writer.cc b/src/tools/dcpomatic_disk_writer.cc
index f789c586d..a31a7673f 100644
--- a/src/tools/dcpomatic_disk_writer.cc
+++ b/src/tools/dcpomatic_disk_writer.cc
@@ -18,6 +18,7 @@
*/
+
#include "lib/compose.hpp"
#include "lib/cross.h"
#include "lib/dcpomatic_log.h"
@@ -81,9 +82,10 @@ using boost::optional;
#ifdef DCPOMATIC_LINUX
-static PolkitAuthority* polkit_authority = 0;
+static PolkitAuthority* polkit_authority = nullptr;
#endif
-static Nanomsg* nanomsg = 0;
+static Nanomsg* nanomsg = nullptr;
+
struct Parameters
{
@@ -92,6 +94,7 @@ struct Parameters
std::string posix_partition;
};
+
#ifdef DCPOMATIC_LINUX
static
void
@@ -137,7 +140,7 @@ try
{
using namespace boost::algorithm;
- optional<string> s = nanomsg->receive (0);
+ auto s = nanomsg->receive (0);
if (!s) {
return true;
}
@@ -150,8 +153,8 @@ try
nanomsg->send(DISK_WRITER_PONG "\n", LONG_TIMEOUT);
} else if (*s == DISK_WRITER_UNMOUNT) {
/* XXX: should do Linux polkit stuff here */
- optional<string> xml_head = nanomsg->receive (LONG_TIMEOUT);
- optional<string> xml_body = nanomsg->receive (LONG_TIMEOUT);
+ auto xml_head = nanomsg->receive (LONG_TIMEOUT);
+ auto xml_body = nanomsg->receive (LONG_TIMEOUT);
if (!xml_head || !xml_body) {
LOG_DISK_NC("Failed to receive unmount request");
throw CommunicationFailedError ();
@@ -162,8 +165,8 @@ try
throw CommunicationFailedError ();
}
} else if (*s == DISK_WRITER_WRITE) {
- optional<string> dcp_path = nanomsg->receive (LONG_TIMEOUT);
- optional<string> device = nanomsg->receive (LONG_TIMEOUT);
+ auto dcp_path = nanomsg->receive (LONG_TIMEOUT);
+ auto device = nanomsg->receive (LONG_TIMEOUT);
if (!dcp_path || !device) {
LOG_DISK_NC("Failed to receive write request");
throw CommunicationFailedError();
@@ -217,8 +220,8 @@ try
#if defined(DCPOMATIC_LINUX)
polkit_authority = polkit_authority_get_sync (0, 0);
- PolkitSubject* subject = polkit_unix_process_new_for_owner (getppid(), 0, -1);
- Parameters* parameters = new Parameters;
+ auto subject = polkit_unix_process_new_for_owner (getppid(), 0, -1);
+ auto parameters = new Parameters;
parameters->dcp_path = *dcp_path;
parameters->device = *device;
parameters->posix_partition = *device;
@@ -232,7 +235,7 @@ try
polkit_authority, subject, "com.dcpomatic.write-drive", 0, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, 0, polkit_callback, parameters
);
#elif defined(DCPOMATIC_OSX)
- string fast_device = boost::algorithm::replace_first_copy (*device, "/dev/disk", "/dev/rdisk");
+ auto fast_device = boost::algorithm::replace_first_copy (*device, "/dev/disk", "/dev/rdisk");
dcpomatic::write (*dcp_path, fast_device, fast_device + "s1", nanomsg);
#elif defined(DCPOMATIC_WINDOWS)
dcpomatic::write (*dcp_path, *device, "", nanomsg);
@@ -277,7 +280,7 @@ main ()
exit (EXIT_FAILURE);
}
- Glib::RefPtr<Glib::MainLoop> ml = Glib::MainLoop::create ();
+ auto ml = Glib::MainLoop::create ();
Glib::signal_timeout().connect(sigc::ptr_fun(&idle), 500);
ml->run ();
}