summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-01-20 22:59:39 +0100
committerCarl Hetherington <cth@carlh.net>2020-03-28 19:47:28 +0100
commitd7f0a91a308c38cec6343eacc7775a344be2091b (patch)
tree6f3c6739b37b55aac568ed2798383e8c5b0a9f83 /src/lib
parentaf42e5d4cb0a4a22dba645c16e7c0d3de4648290 (diff)
Untested basics of macOS drive finding.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cross.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/lib/cross.cc b/src/lib/cross.cc
index 25647bf3e..72ac11cae 100644
--- a/src/lib/cross.cc
+++ b/src/lib/cross.cc
@@ -544,10 +544,39 @@ running_32_on_64 ()
return false;
}
+#ifdef DCPOMATIC_OSX
+static void
+disk_appeared(DADiskRef disk, void* context)
+{
+ const char* name = DADiskGetBSDName (disk);
+ if (name) {
+ list<Drive>* drives = reinterpret_cast<list<Drive>*> (context);
+ drives->push_back (name, 0, false, optional<string>(), optional<string>());
+ }
+}
+#endif
+
vector<Drive>
get_drives ()
{
vector<Drive> drives;
+
+#ifdef DCPOMATIC_OSX
+ DASessionRef session = DASessionCreate(kCFAllocatorDefault);
+ if (!session) {
+ return drives;
+ }
+
+ DARegisterDiskAppearedCallback (session, NULL, disk_appeared, &drives);
+ CFRunLoopRef run_loop = CFRunLoopGetCurrent ();
+ DASessionScheduleWithRunLoop (session, run_loop, kCFRunLoopDefaultMode);
+ CFRunLoopStop (run_loop);
+ CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.05, 0);
+ DAUnregisterCallback(session, (void *) disk_appeared, &drives);
+ CFRelease(session);
+}
+#endif
+
#ifdef DCPOMATIC_LINUX
using namespace boost::filesystem;