C++11 tidying.
[dcpomatic.git] / src / lib / cross_osx.cc
index 8f057c2bfc5cf38307f721142e860e217bd034f0..58ec8e3c46cd6cb6d4b2a228de5086eab0469b2c 100644 (file)
@@ -65,7 +65,7 @@ using std::runtime_error;
 using std::map;
 using std::shared_ptr;
 using boost::optional;
-using boost::function;
+using std::function;
 
 /** @param s Number of seconds to sleep for */
 void
@@ -99,19 +99,7 @@ cpu_info ()
 boost::filesystem::path
 directory_containing_executable ()
 {
-#if BOOST_VERSION >= 106100
        return boost::dll::program_location().parent_path();
-#else
-       uint32_t size = 1024;
-       char buffer[size];
-       if (_NSGetExecutablePath (buffer, &size)) {
-               throw runtime_error ("_NSGetExecutablePath failed");
-       }
-
-       boost::filesystem::path path (buffer);
-       path = boost::filesystem::canonical (path);
-       return path.parent_path ();
-#endif
 }
 
 
@@ -275,7 +263,12 @@ get_vendor (CFDictionaryRef& description)
                return {};
        }
 
-       string s = CFStringGetCStringPtr ((CFStringRef) str, kCFStringEncodingUTF8);
+       auto c_str = CFStringGetCStringPtr ((CFStringRef) str, kCFStringEncodingUTF8);
+       if (!c_str) {
+               return {};
+       }
+
+       string s (c_str);
        boost::algorithm::trim (s);
        return s;
 }
@@ -288,7 +281,12 @@ get_model (CFDictionaryRef& description)
                return {};
        }
 
-       string s = CFStringGetCStringPtr ((CFStringRef) str, kCFStringEncodingUTF8);
+       auto c_str = CFStringGetCStringPtr ((CFStringRef) str, kCFStringEncodingUTF8);
+       if (!c_str) {
+               return {};
+       }
+
+       string s (c_str);
        boost::algorithm::trim (s);
        return s;
 }
@@ -415,6 +413,7 @@ disk_appeared (DADiskRef disk, void* context)
 {
        auto bsd_name = DADiskGetBSDName (disk);
        if (!bsd_name) {
+               LOG_DISK_NC("Disk with no BSDName appeared");
                return;
        }
        LOG_DISK("%1 appeared", bsd_name);
@@ -422,6 +421,7 @@ disk_appeared (DADiskRef disk, void* context)
        Disk this_disk;
 
        this_disk.mount_point = string("/dev/") + bsd_name;
+       LOG_DISK("Mount point is %1", this_disk.mount_point);
 
        CFDictionaryRef description = DADiskCopyDescription (disk);
 
@@ -607,3 +607,10 @@ dcpomatic::get_process_id ()
 {
        return dcp::raw_convert<string>(getpid());
 }
+
+
+boost::filesystem::path
+fix_long_path (boost::filesystem::path path)
+{
+       return path;
+}