Debian Codegraph @

examples/book/giomm/volumes/main.cc

raw
1 #include <giomm.h>
2 #include <iostream>
3
4 int main(int /* argc */, char** /* argv */)
5 {
6 Gio::init();
7
8 try
9 {
10 auto volume_monitor = Gio::VolumeMonitor::get();
11 if(!volume_monitor)
12 std::cerr << "Gio::VolumeMonitor::get() failed." << std::endl;
13
14 //Get the drives:
15 for(const auto& drive : volume_monitor->get_connected_drives())
16 {
17 std::cout << "Drive: " << drive->get_name() << std::endl;
18
19 //Get the volumes in the drive:
20 //TODO: This doesn't seem to be per-drive:
21 for(const auto& volume : volume_monitor->get_volumes())
22 {
23 std::cout << " Volume: " << volume->get_name() << std::endl;
24 }
25 }
26 }
27 catch(const Glib::Error& ex)
28 {
29 std::cerr << "Exception caught: " << ex.what() << std::endl;
30 }
31
32
33
34 return 0;
35 }
36