X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcross_osx.cc;h=58ec8e3c46cd6cb6d4b2a228de5086eab0469b2c;hb=8963f0007af1a312017b9627c18b82ec2a577591;hp=8f057c2bfc5cf38307f721142e860e217bd034f0;hpb=cee8e46df464201d8be1502e4c1b03061dbfc980;p=dcpomatic.git diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc index 8f057c2bf..58ec8e3c4 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -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(getpid()); } + + +boost::filesystem::path +fix_long_path (boost::filesystem::path path) +{ + return path; +}