PrusaSlicer-NonPlainar/src/slic3r/GUI/RemovableDriveManager.hpp

48 lines
1.3 KiB
C++
Raw Normal View History

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:
2019-11-28 12:50:58 +00:00
static RemovableDriveManager& get_instance()
2019-11-26 13:19:29 +00:00
{
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-28 12:50:58 +00:00
bool update(long time = 0); //time = 0 is forced update
bool is_drive_mounted(const std::string &path);
void eject_drive(const std::string &path);
std::string get_last_drive_path();
std::vector<DriveData> get_all_drives();
bool is_path_on_removable_drive(const std::string &path);
void add_callback(std::function<void()> callback);
void print();
2019-11-26 13:19:29 +00:00
private:
RemovableDriveManager(){}
2019-11-28 12:50:58 +00:00
void search_for_drives();
void check_and_notify();
std::vector<DriveData> m_current_drives;
std::vector<std::function<void()>> m_callbacks;
2019-11-26 14:52:18 +00:00
#if _WIN32
2019-11-28 12:50:58 +00:00
void register_window();
2019-11-26 14:52:18 +00:00
#else
2019-11-28 12:50:58 +00:00
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