2019-11-26 13:19:29 +00:00
|
|
|
#ifndef slic3r_GUI_RemovableDriveManager_hpp_
|
|
|
|
#define slic3r_GUI_RemovableDriveManager_hpp_
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
|
|
|
struct DriveData
|
|
|
|
{
|
2019-11-26 14:52:18 +00:00
|
|
|
std::string name;
|
2019-11-26 13:19:29 +00:00
|
|
|
std::string path;
|
2019-11-26 14:52:18 +00:00
|
|
|
DriveData(std::string n, std::string p):name(n),path(p){}
|
2019-11-26 13:19:29 +00:00
|
|
|
};
|
|
|
|
class RemovableDriveManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static RemovableDriveManager& getInstance()
|
|
|
|
{
|
|
|
|
static RemovableDriveManager instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
RemovableDriveManager(RemovableDriveManager const&) = delete;
|
|
|
|
void operator=(RemovableDriveManager const&) = delete;
|
|
|
|
|
|
|
|
//update() searches for removable devices, returns false if empty.
|
2019-11-27 14:47:37 +00:00
|
|
|
static bool update(long time = 0); //time = 0 is forced update
|
2019-11-27 10:33:36 +00:00
|
|
|
static bool is_drive_mounted(const std::string &path);
|
|
|
|
static void eject_drive(const std::string &path);
|
|
|
|
static std::string get_last_drive_path();
|
|
|
|
static std::vector<DriveData> get_all_drives();
|
2019-11-27 12:30:45 +00:00
|
|
|
static bool is_path_on_removable_drive(const std::string &path);
|
2019-11-28 12:38:08 +00:00
|
|
|
static void add_callback(std::function<void()> callback);
|
|
|
|
static void print();
|
2019-11-26 13:19:29 +00:00
|
|
|
private:
|
|
|
|
RemovableDriveManager(){}
|
2019-11-27 10:33:36 +00:00
|
|
|
static void search_for_drives();
|
2019-11-28 12:38:08 +00:00
|
|
|
static void check_and_notify();
|
2019-11-27 10:33:36 +00:00
|
|
|
static std::vector<DriveData> m_current_drives;
|
2019-11-28 12:38:08 +00:00
|
|
|
static std::vector<std::function<void()>> m_callbacks;
|
2019-11-26 14:52:18 +00:00
|
|
|
#if _WIN32
|
2019-11-28 12:38:08 +00:00
|
|
|
static void register_window();
|
2019-11-26 14:52:18 +00:00
|
|
|
#else
|
2019-11-27 10:33:36 +00:00
|
|
|
static void search_path(const std::string &path, const dev_t &parentDevID);
|
2019-11-26 14:52:18 +00:00
|
|
|
#endif
|
2019-11-26 13:19:29 +00:00
|
|
|
};
|
|
|
|
}}
|
|
|
|
#endif
|