C++11 tidying.
[dcpomatic.git] / src / tools / dcpomatic_disk_writer.cc
index ef384bbbac5d27b2bd0967d98f3c9c818234ead3..dca09f729ad0ee37bbd4e12906ceac98d4fe146a 100644 (file)
@@ -31,7 +31,7 @@
 #include "lib/nanomsg.h"
 #include "lib/util.h"
 #include "lib/version.h"
-#include "lib/warnings.h"
+#include <dcp/warnings.h>
 
 #ifdef DCPOMATIC_POSIX
 #include <sys/ioctl.h>
@@ -45,6 +45,7 @@
 extern "C" {
 #include <lwext4/file_dev.h>
 }
+#include <unistd.h>
 #include <xpc/xpc.h>
 #endif
 
@@ -59,9 +60,9 @@ extern "C" {
 }
 #endif
 
-DCPOMATIC_DISABLE_WARNINGS
+LIBDCP_DISABLE_WARNINGS
 #include <glibmm.h>
-DCPOMATIC_ENABLE_WARNINGS
+LIBDCP_ENABLE_WARNINGS
 
 #include <unistd.h>
 #include <sys/types.h>
@@ -176,13 +177,19 @@ try
                        "com.dcpomatic.write-drive",
                        [xml]() {
                                bool const success = Drive(xml).unmount();
-                               if (!nanomsg->send(success ? (DISK_WRITER_OK "\n") : (DISK_WRITER_ERROR "\n"), LONG_TIMEOUT)) {
+                               bool sent_reply = false;
+                               if (success) {
+                                       sent_reply = nanomsg->send(DISK_WRITER_OK "\n", LONG_TIMEOUT);
+                               } else {
+                                       sent_reply = nanomsg->send(DISK_WRITER_ERROR "\nCould not unmount drive\n1\n", LONG_TIMEOUT);
+                               }
+                               if (!sent_reply) {
                                        LOG_DISK_NC("CommunicationFailedError in unmount_finished");
                                        throw CommunicationFailedError ();
                                }
                        },
                        []() {
-                               if (!nanomsg->send(DISK_WRITER_ERROR "\n", LONG_TIMEOUT)) {
+                               if (!nanomsg->send(DISK_WRITER_ERROR "\nCould not get permission to unmount drive\n1\n", LONG_TIMEOUT)) {
                                        LOG_DISK_NC("CommunicationFailedError in unmount_finished");
                                        throw CommunicationFailedError ();
                                }
@@ -265,7 +272,7 @@ try
                        },
                        []() {
                                if (nanomsg) {
-                                       nanomsg->send(DISK_WRITER_ERROR "\nCould not obtain authorization to write to the drive\n", LONG_TIMEOUT);
+                                       nanomsg->send(DISK_WRITER_ERROR "\nCould not obtain authorization to write to the drive\n1\n", LONG_TIMEOUT);
                                }
                        });
        }
@@ -285,7 +292,7 @@ main ()
         * redirect this to a file in /var/log
         */
        dcpomatic_log.reset(new StdoutLog(LogEntry::TYPE_DISK));
-       LOG_DISK("dcpomatic_disk_writer %1 started", dcpomatic_git_commit);
+       LOG_DISK("dcpomatic_disk_writer %1 started uid=%2 euid=%3", dcpomatic_git_commit, getuid(), geteuid());
 #else
        /* XXX: this is a hack, but I expect we'll need logs and I'm not sure if there's
         * a better place to put them.