macos list devices
This commit is contained in:
parent
c3653589f6
commit
c37128ad63
4 changed files with 42 additions and 35 deletions
|
@ -218,11 +218,11 @@ INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
|||
#else
|
||||
void RemovableDriveManager::search_for_drives()
|
||||
{
|
||||
/*
|
||||
|
||||
#if __APPLE__
|
||||
list_devices();
|
||||
#endif
|
||||
*/
|
||||
|
||||
m_current_drives.clear();
|
||||
m_current_drives.reserve(26);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
void reset_last_save_path();
|
||||
void print();
|
||||
private:
|
||||
RemovableDriveManager():m_drives_count(0),m_last_update(0),m_last_save_path(""){}
|
||||
RemovableDriveManager():m_drives_count(0),m_last_update(0),m_last_save_path(""),m_rdmmm(nullptr){}
|
||||
void search_for_drives();
|
||||
void check_and_notify();
|
||||
std::string get_drive_from_path(const std::string& path);//returns drive path (same as path in DriveData) if exists otherwise empty string ""
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
#elif __APPLE__
|
||||
void *m_rdmmm;
|
||||
void register_window();
|
||||
//void list_devices();
|
||||
void list_devices();
|
||||
void search_path(const std::string &path, const std::string &parent_path);
|
||||
bool compare_filesystem_id(const std::string &path_a, const std::string &path_b);
|
||||
#else
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
-(instancetype) init;
|
||||
-(void) add_unmount_observer;
|
||||
-(void) on_device_unmount: (NSNotification*) notification;
|
||||
|
||||
@end
|
||||
-(void) list_dev;
|
||||
@end
|
||||
|
|
|
@ -25,6 +25,36 @@
|
|||
NSLog(@"add unmount observer");
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
|
||||
}
|
||||
-(void) list_dev
|
||||
{
|
||||
NSLog(@"---");
|
||||
NSArray* devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
|
||||
for (NSString* volumePath in devices)
|
||||
{
|
||||
NSLog(@"@", volumePath);
|
||||
}
|
||||
NSLog(@"--");
|
||||
//removable here means CD not USB :/
|
||||
NSArray* listOfMedia = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths];
|
||||
NSLog(@"%@", listOfMedia);
|
||||
|
||||
for (NSString* volumePath in listOfMedia)
|
||||
{
|
||||
BOOL isRemovable = NO;
|
||||
BOOL isWritable = NO;
|
||||
BOOL isUnmountable = NO;
|
||||
NSString* description = [NSString string];
|
||||
NSString* type = [NSString string];
|
||||
|
||||
BOOL result = [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath:volumePath
|
||||
isRemovable:&isRemovable
|
||||
isWritable:&isWritable
|
||||
isUnmountable:&isUnmountable
|
||||
description:&description
|
||||
type:&type];
|
||||
NSLog(@"Result:%i Volume: %@, Removable:%i, W:%i, Unmountable:%i, Desc:%@, type:%@", result, volumePath, isRemovable, isWritable, isUnmountable, description, type);
|
||||
}
|
||||
}
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
void RemovableDriveManager::register_window()
|
||||
|
@ -32,39 +62,16 @@ void RemovableDriveManager::register_window()
|
|||
m_rdmmm = nullptr;
|
||||
m_rdmmm = [[RemovableDriveManagerMM alloc] init];
|
||||
}
|
||||
void RemovableDriveManager::list_devices()
|
||||
{
|
||||
if(m_rdmmm == nullptr)
|
||||
return;
|
||||
[m_rdmmm list_dev];
|
||||
}
|
||||
}}//namespace Slicer::GUI
|
||||
|
||||
/*
|
||||
-(void) RemovableDriveManager::list_devices()
|
||||
{
|
||||
NSLog(@"---");
|
||||
NSArray* devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
|
||||
for (NSString* volumePath in listOfMedia)
|
||||
{
|
||||
NSLog(@"@", volumePath);
|
||||
}
|
||||
NSLog(@"--");
|
||||
//removable here means CD not USB :/
|
||||
NSArray* listOfMedia = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths];
|
||||
NSLog(@"%@", listOfMedia);
|
||||
|
||||
for (NSString* volumePath in listOfMedia)
|
||||
{
|
||||
BOOL isRemovable = NO;
|
||||
BOOL isWritable = NO;
|
||||
BOOL isUnmountable = NO;
|
||||
NSString* description = [NSString string];
|
||||
NSString* type = [NSString string];
|
||||
|
||||
BOOL result = [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath:volumePath
|
||||
isRemovable:&isRemovable
|
||||
isWritable:&isWritable
|
||||
isUnmountable:&isUnmountable
|
||||
description:&description
|
||||
type:&type];
|
||||
NSLog(@"Result:%i Volume: %@, Removable:%i, W:%i, Unmountable:%i, Desc:%@, type:%@", result, volumePath, isRemovable, isWritable, isUnmountable, description, type);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue