Change video content scaling so that it either:
[dcpomatic.git] / hacks / drives.cc
1 #include <boost/filesystem.hpp>
2 #include <boost/algorithm/string.hpp>
3 #include <iostream>
4 #include <string>
5
6 using std::cout;
7 using std::cerr;
8 using std::string;
9
10 int main ()
11 {
12         if (!boost::filesystem::exists("/sys/block")) {
13                 cerr << "Could not find /sys/block\n";
14                 exit (EXIT_FAILURE);
15         }
16
17         for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator("/sys/block"); i != boost::filesystem::directory_iterator(); ++i) {
18                 if (boost::starts_with(i->path().filename().string(), "loop")) {
19                         continue;
20                 }
21
22                 string model;
23                 boost::filesystem::path device = i->path() / "device" / "model";
24                 FILE* f = fopen(device.string().c_str(), "r");
25                 if (f) {
26                         char buffer[128];
27                         fgets (buffer, 128, f);
28                         model = buffer;
29                         boost::trim (model);
30                         fclose (f);
31                 }
32
33                 cout << i->path() << " " << model << "\n";
34         }
35
36         return 0;
37 }
38