Welcome to mirror list, hosted at ThFree Co, Russian Federation.

RemovableDriveManager.hpp « GUI « slic3r « src - github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f3abc4207396aa5e07259357ce98301f23814ceb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef slic3r_GUI_RemovableDriveManager_hpp_
#define slic3r_GUI_RemovableDriveManager_hpp_

#include <vector>
#include <string>

namespace Slic3r {
namespace GUI {
struct DriveData
{
	std::string name;
	std::string path;
	DriveData(std::string n, std::string p):name(n),path(p){}
};
class RemovableDriveManager
{
public:
	static RemovableDriveManager& get_instance()
	{
		static RemovableDriveManager instance; 
		return instance;
	}
	RemovableDriveManager(RemovableDriveManager const&) = delete;
	void operator=(RemovableDriveManager const&) = delete;
	
	//update() searches for removable devices, returns false if empty.
	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();
private:
	RemovableDriveManager(){}
	void search_for_drives();
	void check_and_notify();
	std::vector<DriveData> m_current_drives;
	std::vector<std::function<void()>> m_callbacks;
#if _WIN32
	void register_window();
#else
	void search_path(const std::string &path, const dev_t &parentDevID);
#endif
};
}}
#endif