macos list devices
This commit is contained in:
parent
40a83e67dd
commit
3b6daf64c7
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
|
#else
|
||||||
void RemovableDriveManager::search_for_drives()
|
void RemovableDriveManager::search_for_drives()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
list_devices();
|
list_devices();
|
||||||
#endif
|
#endif
|
||||||
*/
|
|
||||||
m_current_drives.clear();
|
m_current_drives.clear();
|
||||||
m_current_drives.reserve(26);
|
m_current_drives.reserve(26);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
void reset_last_save_path();
|
void reset_last_save_path();
|
||||||
void print();
|
void print();
|
||||||
private:
|
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 search_for_drives();
|
||||||
void check_and_notify();
|
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 ""
|
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__
|
#elif __APPLE__
|
||||||
void *m_rdmmm;
|
void *m_rdmmm;
|
||||||
void register_window();
|
void register_window();
|
||||||
//void list_devices();
|
void list_devices();
|
||||||
void search_path(const std::string &path, const std::string &parent_path);
|
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);
|
bool compare_filesystem_id(const std::string &path_a, const std::string &path_b);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
-(instancetype) init;
|
-(instancetype) init;
|
||||||
-(void) add_unmount_observer;
|
-(void) add_unmount_observer;
|
||||||
-(void) on_device_unmount: (NSNotification*) notification;
|
-(void) on_device_unmount: (NSNotification*) notification;
|
||||||
|
-(void) list_dev;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -25,6 +25,36 @@
|
||||||
NSLog(@"add unmount observer");
|
NSLog(@"add unmount observer");
|
||||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
|
[[[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 Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
void RemovableDriveManager::register_window()
|
void RemovableDriveManager::register_window()
|
||||||
|
@ -32,39 +62,16 @@ void RemovableDriveManager::register_window()
|
||||||
m_rdmmm = nullptr;
|
m_rdmmm = nullptr;
|
||||||
m_rdmmm = [[RemovableDriveManagerMM alloc] init];
|
m_rdmmm = [[RemovableDriveManagerMM alloc] init];
|
||||||
}
|
}
|
||||||
|
void RemovableDriveManager::list_devices()
|
||||||
|
{
|
||||||
|
if(m_rdmmm == nullptr)
|
||||||
|
return;
|
||||||
|
[m_rdmmm list_dev];
|
||||||
|
}
|
||||||
}}//namespace Slicer::GUI
|
}}//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
|
@end
|
||||||
|
|
Loading…
Add table
Reference in a new issue