summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-04-21 23:13:54 +0200
committerCarl Hetherington <cth@carlh.net>2021-04-21 23:13:54 +0200
commitac1330abe202e31207baa00a3949e446e2c9d3cb (patch)
treeb4c4cabe343c95c2befa7d13f822b97bb6edf42d
parent71a2fc5432d9cb6f8588fec56cc28e623810f6ee (diff)
C++11 tidying.
-rw-r--r--src/lib/cross_linux.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc
index 7e026b9a6..8ce72d6fc 100644
--- a/src/lib/cross_linux.cc
+++ b/src/lib/cross_linux.cc
@@ -311,10 +311,10 @@ Drive::get ()
vector<Drive> drives;
using namespace boost::filesystem;
- vector<pair<string, string> > mounted_devices = get_mounts("/dev/");
+ auto mounted_devices = get_mounts("/dev/");
- for (directory_iterator i = directory_iterator("/sys/block"); i != directory_iterator(); ++i) {
- string const name = i->path().filename().string();
+ for (auto i: directory_iterator("/sys/block")) {
+ string const name = i.path().filename().string();
path device_type_file("/sys/block/" + name + "/device/type");
optional<string> device_type;
if (exists(device_type_file)) {
@@ -323,7 +323,7 @@ Drive::get ()
}
/* Device type 5 is "SCSI_TYPE_ROM" in blkdev.h; seems usually to be a CD/DVD drive */
if (!boost::algorithm::starts_with(name, "loop") && (!device_type || *device_type != "5")) {
- uint64_t const size = dcp::raw_convert<uint64_t>(dcp::file_to_string(*i / "size")) * 512;
+ uint64_t const size = dcp::raw_convert<uint64_t>(dcp::file_to_string(i / "size")) * 512;
if (size == 0) {
continue;
}
@@ -338,9 +338,9 @@ Drive::get ()
boost::trim(*model);
} catch (...) {}
vector<boost::filesystem::path> mount_points;
- for (vector<pair<string, string> >::const_iterator j = mounted_devices.begin(); j != mounted_devices.end(); ++j) {
- if (boost::algorithm::starts_with(j->first, "/dev/" + name)) {
- mount_points.push_back (j->second);
+ for (auto const& j: mounted_devices) {
+ if (boost::algorithm::starts_with(j.first, "/dev/" + name)) {
+ mount_points.push_back (j.second);
}
}
drives.push_back(Drive("/dev/" + name, mount_points, size, vendor, model));