#include <devicedisk.h>
DeviceDisk::DeviceDisk |
( |
| ) |
|
181 vector <info> result;
183 #ifdef COSMOS_LINUX_OS 188 vector<string> lines;
194 for (
string line : lines)
197 if (sscanf(line.c_str(),
"%lu %s\n", &tsize, tmount) == 2 && tmount[0] ==
'/')
199 tinfo.mount = tmount;
201 tinfo.used =
getUsed(tinfo.mount);
202 tinfo.free = tinfo.size - tinfo.used;
203 result.push_back(tinfo);
228 result.push_back(tinfo);
234 result.push_back(tinfo);
int iretn
Definition: rw_test.cpp:37
uint64_t getUsed()
Definition: devicedisk.cpp:116
int32_t data_execute(string cmd, string &result, string shell)
Definition: datalib.cpp:1947
double getAll()
Definition: devicedisk.cpp:9
uint64_t Size
Definition: devicedisk.h:35
uint64_t Free
Definition: devicedisk.h:37
backing_store_ptr info
Definition: jmemsys.h:181
uint64_t Used
Definition: devicedisk.h:36
vector< string > string_split(string in, string delimeters)
Parse a string.
Definition: stringlib.cpp:47
double DeviceDisk::getAll |
( |
string |
path | ) |
|
27 #if defined COSMOS_LINUX_OS 30 statvfs(path.c_str(),&
buf);
34 Size = (uint64_t)
buf.f_frsize * (uint64_t)
buf.f_blocks;
35 Free = (uint64_t)
buf.f_frsize * (uint64_t)
buf.f_bfree;
39 #if defined COSMOS_MAC_OS 41 uint32_t dev = open(
"/dev/disk0", O_RDONLY);
44 perror(
"Failed to open disk");
48 uint64_t sector_count = 0;
50 ioctl(dev, DKIOCGETBLOCKCOUNT, §or_count);
52 uint32_t sector_size = 0;
54 ioctl(dev, DKIOCGETBLOCKSIZE, §or_size);
56 uint64_t disk_size = sector_count * sector_size;
57 printf(
"%ld", disk_size);
64 #if defined COSMOS_WIN_OS 67 GetDiskFreeSpaceExA( (LPCSTR) path.c_str(),
68 (PULARGE_INTEGER)&freeSpace,
69 (PULARGE_INTEGER)&
Size,
70 (PULARGE_INTEGER)&
Free);
static const double GiB
Definition: devicedisk.h:30
double SizeGiB
Definition: devicedisk.h:38
double FreeGiB
Definition: devicedisk.h:40
uint64_t Size
Definition: devicedisk.h:35
uint64_t Free
Definition: devicedisk.h:37
double FreePercent
Definition: devicedisk.h:41
char buf[128]
Definition: rw_test.cpp:40
uint64_t Used
Definition: devicedisk.h:36
double UsedGiB
Definition: devicedisk.h:39
uint64_t DeviceDisk::getSize |
( |
string |
path | ) |
|
double getAll()
Definition: devicedisk.cpp:9
uint64_t Size
Definition: devicedisk.h:35
uint64_t DeviceDisk::getUsed |
( |
string |
path | ) |
|
double getAll()
Definition: devicedisk.cpp:9
uint64_t Used
Definition: devicedisk.h:36
uint64_t DeviceDisk::getFree |
( |
string |
path | ) |
|
double getAll()
Definition: devicedisk.cpp:9
uint64_t Free
Definition: devicedisk.h:37
double DeviceDisk::getAll |
( |
| ) |
|
11 #if defined COSMOS_LINUX_OS 15 #if defined COSMOS_WIN_OS double getAll()
Definition: devicedisk.cpp:9
uint64_t DeviceDisk::getSize |
( |
| ) |
|
87 #if defined COSMOS_LINUX_OS 91 #if defined COSMOS_WIN_OS uint64_t getSize()
Definition: devicedisk.cpp:85
uint64_t DeviceDisk::getUsed |
( |
| ) |
|
118 #if defined COSMOS_LINUX_OS 122 #if defined COSMOS_WIN_OS uint64_t getUsed()
Definition: devicedisk.cpp:116
uint64_t DeviceDisk::getFree |
( |
| ) |
|
149 #if defined COSMOS_LINUX_OS 153 #if defined COSMOS_WIN_OS uint64_t getFree()
Definition: devicedisk.cpp:147
double DeviceDisk::getFreeGiB |
( |
string |
path | ) |
|
static const double GiB
Definition: devicedisk.h:30
uint64_t getFree()
Definition: devicedisk.cpp:147
double DeviceDisk::getUsedGiB |
( |
string |
path | ) |
|
static const double GiB
Definition: devicedisk.h:30
uint64_t getUsed()
Definition: devicedisk.cpp:116
double DeviceDisk::getSizeGiB |
( |
string |
path | ) |
|
static const double GiB
Definition: devicedisk.h:30
uint64_t getSize()
Definition: devicedisk.cpp:85
double DeviceDisk::getFreeGiB |
( |
| ) |
|
static const double GiB
Definition: devicedisk.h:30
uint64_t getFree()
Definition: devicedisk.cpp:147
double DeviceDisk::getUsedGiB |
( |
| ) |
|
static const double GiB
Definition: devicedisk.h:30
uint64_t getUsed()
Definition: devicedisk.cpp:116
double DeviceDisk::getSizeGiB |
( |
| ) |
|
static const double GiB
Definition: devicedisk.h:30
uint64_t getSize()
Definition: devicedisk.cpp:85
uint64_t DeviceDisk::Size |
uint64_t DeviceDisk::Used |
uint64_t DeviceDisk::Free |
double DeviceDisk::SizeGiB |
double DeviceDisk::UsedGiB |
double DeviceDisk::FreeGiB |
double DeviceDisk::FreePercent |
The documentation for this class was generated from the following files: