diff options
author | Ken Moore <moorekou@gmail.com> | 2015-03-27 09:09:14 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-03-27 09:09:14 -0400 |
commit | 7b1ab034672afbaae201b0a875c0d202bc2c65b0 (patch) | |
tree | 7c2ab89d883ea7c6177a788f1642291775a019d7 /libLumina | |
parent | Streamline quite a bit of the background worker: (diff) | |
parent | minor string change (diff) | |
download | lumina-7b1ab034672afbaae201b0a875c0d202bc2c65b0.tar.gz lumina-7b1ab034672afbaae201b0a875c0d202bc2c65b0.tar.bz2 lumina-7b1ab034672afbaae201b0a875c0d202bc2c65b0.zip |
Merge pull request #78 from Nanolx/master
LuminaOS-Debian #6
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaOS-Debian.cpp | 17 | ||||
-rw-r--r-- | libLumina/LuminaOS-Linux.cpp | 13 |
2 files changed, 26 insertions, 4 deletions
diff --git a/libLumina/LuminaOS-Debian.cpp b/libLumina/LuminaOS-Debian.cpp index b0da7586..7ce8250f 100644 --- a/libLumina/LuminaOS-Debian.cpp +++ b/libLumina/LuminaOS-Debian.cpp @@ -195,12 +195,25 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining //File Checksums QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file - return QStringList(); + QStringList info = LUtils::getCmdOutput("md5sum \""+filepaths.join("\" \"")+"\""); + for(int i=0; i<info.length(); i++){ + // first: md5sum: = error ; second: there's always one empty entry generated by getCmdOutput + if( info[i].startsWith("md5sum:") || info[i].isEmpty()){ info.removeAt(i); i--; } + else{ + //Strip out the extra information + info[i] = info[i].section(" ",0,0); + } + } + return info; } //file system capacity QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command - return QString(); + QStringList mountInfo = LUtils::getCmdOutput("df -h \"" + dir + "\""); + QString::SectionFlag skipEmpty = QString::SectionSkipEmpty; + //output: 200G of 400G available on /mount/point + QString capacity = mountInfo[1].section(" ",3,3, skipEmpty) + " of " + mountInfo[1].section(" ",1,1, skipEmpty) + " available on " + mountInfo[1].section(" ",5,5, skipEmpty); + return capacity; } #endif diff --git a/libLumina/LuminaOS-Linux.cpp b/libLumina/LuminaOS-Linux.cpp index 5a800cc5..46a6371a 100644 --- a/libLumina/LuminaOS-Linux.cpp +++ b/libLumina/LuminaOS-Linux.cpp @@ -192,7 +192,16 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining //File Checksums QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file - return QStringList(); + QStringList info = LUtils::getCmdOutput("md5sum \""+filepaths.join("\" \"")+"\""); + for(int i=0; i<info.length(); i++){ + // first: md5sum: = error ; second: there's always one empty entry generated by getCmdOutput + if( info[i].startsWith("md5sum:") || info[i].isEmpty()){ info.removeAt(i); i--; } + else{ + //Strip out the extra information + info[i] = info[i].section(" ",0,0); + } + } + return info; } //file system capacity @@ -200,7 +209,7 @@ QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as QStringList mountInfo = LUtils::getCmdOutput("df \"" + dir+"\""); QString::SectionFlag skipEmpty = QString::SectionSkipEmpty; //we take the 5th word on the 2 line - QString capacity = mountInfo[1].section(" ",4,4, skipEmpty); + QString capacity = mountInfo[1].section(" ",4,4, skipEmpty) + " used"; return capacity; } #endif |