diff options
author | David Kocik <kocikdav@gmail.com> | 2020-03-09 16:25:02 +0300 |
---|---|---|
committer | David Kocik <kocikdav@gmail.com> | 2020-03-09 17:34:26 +0300 |
commit | 0836df93e1f1692544fcdc8a89677f321c57f66a (patch) | |
tree | 3df481e4e7c7a47269f0d22747eea92b2d6e7489 /src | |
parent | 56fa84c9d93abfe2fe119a1c013637144a29e754 (diff) |
enumarating removable drives on mac - added Secure Digital option
hopefully a fix for issue #3793
Diffstat (limited to 'src')
-rw-r--r-- | src/slic3r/GUI/RemovableDriveManager.cpp | 6 | ||||
-rw-r--r-- | src/slic3r/GUI/RemovableDriveManagerMM.mm | 27 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 0c4c417b2..1580c5025 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -338,9 +338,11 @@ void RemovableDriveManager::eject_drive() // there is no usable command in c++ so terminal command is used instead // but neither triggers "succesful safe removal messege" std::string command = -#if __APPLE__ - //this->eject_device(m_last_save_path); +#if __APPLE__ "diskutil unmount "; + //Another option how to eject at mac. Currently not working. + //used insted of system() command; + //this->eject_device(correct_path); #else "umount "; #endif diff --git a/src/slic3r/GUI/RemovableDriveManagerMM.mm b/src/slic3r/GUI/RemovableDriveManagerMM.mm index c2f55bb79..3e4b32f29 100644 --- a/src/slic3r/GUI/RemovableDriveManagerMM.mm +++ b/src/slic3r/GUI/RemovableDriveManagerMM.mm @@ -4,9 +4,21 @@ #import <AppKit/AppKit.h> #import <DiskArbitration/DiskArbitration.h> -@implementation RemovableDriveManagerMM +static void eject_callback(DADiskRef disk, DADissenterRef dissenter, void *context) +{ + NSLog(@"eject successfull"); +} +static void unmount_callback(DADiskRef disk, DADissenterRef dissenter, void *context) +{ + //if (dissenter) { + //? + //} else { + DADiskEject(disk, kDADiskEjectOptionDefault, eject_callback, context); + //} +} +@implementation RemovableDriveManagerMM -(instancetype) init { @@ -59,9 +71,17 @@ CFTypeRef mediaEjectableKey = CFDictionaryGetValue(descDict,kDADiskDescriptionMediaEjectableKey); BOOL ejectable = [mediaEjectableKey boolValue]; CFTypeRef deviceProtocolName = CFDictionaryGetValue(descDict,kDADiskDescriptionDeviceProtocolKey); + CFTypeRef deviceModelKey = CFDictionaryGetValue(descDict, kDADiskDescriptionDeviceModelKey); + //debug logging + /* + if (deviceProtocolName) + NSLog(@"%@",(CFStringRef)deviceProtocolName); + if (deviceModelKey) + NSLog(@"-%@",(CFStringRef)deviceModelKey); + */ if (mediaEjectableKey != nullptr) { - BOOL op = ejectable && (CFEqual(deviceProtocolName, CFSTR("USB")) || CFEqual(deviceModelKey, CFSTR("SD Card Reader"))); + BOOL op = ejectable && (CFEqual(deviceProtocolName, CFSTR("USB")) || CFEqual(deviceModelKey, CFSTR("SD Card Reader")) || CFEqual(deviceProtocolName, CFSTR("Secure Digital"))); //!CFEqual(deviceModelKey, CFSTR("Disk Image")); if (op) [result addObject:volURL.path]; @@ -86,7 +106,8 @@ if (err == 0) disk = DADiskCreateFromVolumePath(nullptr,session,(CFURLRef)url); if( err == 0) - DADiskUnmount(disk, kDADiskUnmountOptionDefault, nullptr, nullptr); + //DADiskUnmount(disk, kDADiskUnmountOptionDefault, nullptr, nullptr); + DADiskUnmount(disk, kDADiskUnmountOptionWhole | kDADiskUnmountOptionForce, unmount_callback, nullptr); if (disk != nullptr) CFRelease(disk); if (session != nullptr) |