diff --git a/src/drive.cpp b/src/drive.cpp index c7b4e45..87dd50a 100644 --- a/src/drive.cpp +++ b/src/drive.cpp @@ -48,17 +48,17 @@ uint32_t Drive::getPowerCycles(void) string Drive::sCapacityToText() { - if(getCapacity() <= (999*1000000000UL)) - { - // Less or even 999 GB --> GB - return to_string(getCapacity() / 1000000000UL) + " GB"; - } - else - { - // More 999 GB --> TB - return to_string(getCapacity() / 1000000000000UL) + " TB"; - } - return "ERROR"; + char acBuffer[16]; + double dSize = (double) getCapacity(); + uint16_t u16UnitIndex = 0; + const char* units[] = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; + while (dSize >= 1000) { //using the marketing capacity + dSize /= 1000; + u16UnitIndex++; + } + + sprintf(acBuffer, "%.*f %s", u16UnitIndex-3, dSize, units[u16UnitIndex]); + return acBuffer; } string Drive::sErrorCountToText() diff --git a/src/reHDD.cpp b/src/reHDD.cpp index 9695079..38fb6ee 100644 --- a/src/reHDD.cpp +++ b/src/reHDD.cpp @@ -343,7 +343,7 @@ void reHDD::filterIgnoredDrives(list * plistDrives) sLine.erase(0, pos + sDelimiter.length()); sIgnoredDriveUUID = sLine; } //end while - vtlIgnoredDevices.emplace_back(sIgnoredDrivePath, sIgnoredDriveUUID); //add found path and uuid from ingnore file to vector + vtlIgnoredDevices.emplace_back(sIgnoredDrivePath, sIgnoredDriveUUID); //add found path and uuid from ignore file to vector } } //loop through found entries in ingnore file @@ -383,7 +383,7 @@ void reHDD::filterIgnoredDrives(list * plistDrives) if (get<1>(row).compare(sUUID)) //compare uuid from ignore file and uuid from drive { cout << "[ERROR] different uuid found than in ignore file:" << it->getPath() << endl; - Logger::logThis()->error("[ERROR] different uuid found than in ignore file: " + it->getPath()); + Logger::logThis()->error("[ERROR] different uuid found than in ignore file: " + it->getPath() + " uuid from drive: " + sUUID); exit(EXIT_FAILURE); // exit to prevent accidentally shred a system drive } else