macos better wrapper
This commit is contained in:
parent
9e4f470f98
commit
44b1a9cf7f
3 changed files with 32 additions and 24 deletions
|
@ -391,13 +391,23 @@ std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
RemovableDriveManager::RemovableDriveManager():
|
||||||
|
m_drives_count(0),
|
||||||
|
m_last_update(0),
|
||||||
|
m_last_save_path(""),
|
||||||
|
#if __APPLE__
|
||||||
|
m_rdmmm(new RDMMMWrapper())
|
||||||
|
#endif
|
||||||
|
{}
|
||||||
|
|
||||||
void RemovableDriveManager::init()
|
void RemovableDriveManager::init()
|
||||||
{
|
{
|
||||||
add_callback([](void) { RemovableDriveManager::get_instance().print(); });
|
add_callback([](void) { RemovableDriveManager::get_instance().print(); });
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
register_window();
|
register_window();
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
register_window();
|
m_rdmmm->register_window();
|
||||||
#endif
|
#endif
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
class RDMMMWrapper;
|
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
|
class RDMMMWrapper;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct DriveData
|
struct DriveData
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,9 @@ struct DriveData
|
||||||
};
|
};
|
||||||
class RemovableDriveManager
|
class RemovableDriveManager
|
||||||
{
|
{
|
||||||
|
#if __APPLE__
|
||||||
|
friend class RDMMMWrapper;
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
static RemovableDriveManager& get_instance()
|
static RemovableDriveManager& get_instance()
|
||||||
{
|
{
|
||||||
|
@ -42,12 +45,9 @@ public:
|
||||||
bool is_last_drive_removed_with_update(const long time = 0); // param as update()
|
bool is_last_drive_removed_with_update(const long time = 0); // param as update()
|
||||||
void reset_last_save_path();
|
void reset_last_save_path();
|
||||||
void print();
|
void print();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if __APPLE__
|
RemovableDriveManager();
|
||||||
RemovableDriveManager():m_drives_count(0),m_last_update(0),m_last_save_path(""),m_rdmmm(new RemovableDriveManagerMM()){}
|
|
||||||
#else
|
|
||||||
RemovableDriveManager() : m_drives_count(0), m_last_update(0), m_last_save_path(""){}
|
|
||||||
#endif
|
|
||||||
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 ""
|
||||||
|
@ -64,21 +64,23 @@ private:
|
||||||
RDMMMWrapper * m_rdmmm;
|
RDMMMWrapper * m_rdmmm;
|
||||||
#endif
|
#endif
|
||||||
void search_path(const std::string &path, const std::string &parent_path);
|
void search_path(const std::string &path, const std::string &parent_path);
|
||||||
void inspect_file(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);
|
||||||
|
void inspect_file(const std::string &path, const std::string &parent_path);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
class RDMMMWrapper
|
|
||||||
{
|
#if __APPLE__
|
||||||
public:
|
class RDMMMWrapper
|
||||||
RDMMMWrapper();
|
{
|
||||||
~RDMMMWrapper();
|
public:
|
||||||
void register_window();
|
RDMMMWrapper();
|
||||||
void list_devices();
|
~RDMMMWrapper();
|
||||||
private:
|
void register_window();
|
||||||
void *m_imp;
|
void list_devices();
|
||||||
friend void RemovableDriveManager::inspect_file(const std::string &path, const std::string &parent_path);
|
protected:
|
||||||
};
|
void *m_imp;
|
||||||
|
//friend void RemovableDriveManager::inspect_file(const std::string &path, const std::string &parent_path);
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
}}
|
}}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,10 +27,6 @@
|
||||||
-(NSArray*) list_dev
|
-(NSArray*) list_dev
|
||||||
{
|
{
|
||||||
NSArray* devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
|
NSArray* devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
|
||||||
for (NSString* volumePath in devices)
|
|
||||||
{
|
|
||||||
NSLog(@"%@", volumePath);
|
|
||||||
}
|
|
||||||
return devices;
|
return devices;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue