-
Notifications
You must be signed in to change notification settings - Fork 6
/
StorageRoster.cpp
60 lines (48 loc) · 1 KB
/
StorageRoster.cpp
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
49
50
51
52
53
54
55
56
57
58
59
/*
* Storages.cpp
*
* Author: Stefano Ceccherini
*/
#include "StorageRoster.h"
#include "ProcReader.h"
#include "Support.h"
#include <iostream>
#include <istream>
StorageRoster::StorageRoster()
{
_ReadStoragesInfo();
}
void
StorageRoster::_ReadStoragesInfo()
{
try {
ProcReader procReader("/proc/scsi/scsi");
std::istream stream(&procReader);
for (;;) {
std::string dummy;
if (!std::getline(stream, dummy))
break;
std::string hostLine;
std::string vendorLine;
std::string typeLine;
if (!std::getline(stream, hostLine))
break;
if (!std::getline(stream, vendorLine))
break;
if (!std::getline(stream, typeLine))
break;
storage_info info;
info.manufacturer = vendorLine.substr(10, 9);
trim(info.manufacturer);
info.model = vendorLine.substr(26, 17);
trim(info.model);
// TODO: Name = Model ?
info.name = info.model;
info.type = typeLine.substr(10, 26);
trim(info.type);
fItems.push_back(info);
}
} catch (...) {
}
Rewind();
}