forked from jackburton79/inventory-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVolumeReader.cpp
More file actions
46 lines (37 loc) · 798 Bytes
/
VolumeReader.cpp
File metadata and controls
46 lines (37 loc) · 798 Bytes
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
/*
* VolumeReader.cpp
*
* Created on: 19/lug/2013
* Author: Stefano Ceccherini
*/
#include "Support.h"
#include "VolumeReader.h"
#include <iostream>
#include <sstream>
VolumeReader::VolumeReader(const char* options)
{
// TODO:
std::string string("export LC_ALL=C; ");
string.append("df ").append(options);
popen_streambuf df(string.c_str(), "r");
std::istream stream(&df);
std::string line;
std::getline(stream, line); // Skip the first line
while (std::getline(stream, line)) {
std::istringstream iss(line);
volume_info info;
std::string dummy;
iss >> info.name;
iss >> info.total;
iss >> dummy;
iss >> info.free;
iss >> dummy;
iss >> info.type;
// TODO: filesystem, other
fItems.push_back(info);
}
Rewind();
}
VolumeReader::~VolumeReader()
{
}