display shred duration after completion
This commit is contained in:
@ -134,7 +134,6 @@ void Drive::setDriveSMARTData( string modelFamily,
|
||||
u32PowerCycles = powerCycle;
|
||||
}
|
||||
|
||||
|
||||
void Drive::setTimestamp()
|
||||
{
|
||||
time(&this->u32Timestamp);
|
||||
@ -150,6 +149,19 @@ time_t Drive::getActionStartTimestamp()
|
||||
return this->u32TimestampTaskStart;
|
||||
}
|
||||
|
||||
void Drive::calculateTaskDuration()
|
||||
{
|
||||
time_t u32localtime;
|
||||
time(&u32localtime);
|
||||
|
||||
this->u32TaskDuration = u32localtime - this->u32TimestampTaskStart;
|
||||
}
|
||||
|
||||
time_t Drive::getTaskDuration()
|
||||
{
|
||||
return this->u32TaskDuration;
|
||||
}
|
||||
|
||||
void Drive::checkFrozenDrive(void)
|
||||
{
|
||||
time_t u32localtime;
|
||||
|
22
src/tui.cpp
22
src/tui.cpp
@ -96,7 +96,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
||||
}
|
||||
|
||||
stringstream stream;
|
||||
time_t u32localtime;
|
||||
|
||||
|
||||
switch (it->state)
|
||||
{
|
||||
@ -105,13 +105,13 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
||||
stream << fixed << setprecision(2) << (it->getTaskPercentage());
|
||||
sState = "Shredding: " + stream.str() + "%";
|
||||
|
||||
time(&u32localtime);
|
||||
sTime = this->calculateTimeDelta(it->getActionStartTimestamp(), u32localtime);
|
||||
it->calculateTaskDuration();
|
||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||
break;
|
||||
case Drive::DELETE_ACTIVE:
|
||||
sState = "Deleting ...";
|
||||
time(&u32localtime);
|
||||
sTime = this->calculateTimeDelta(it->getActionStartTimestamp(), u32localtime);
|
||||
it->calculateTaskDuration();
|
||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||
break;
|
||||
|
||||
case Drive::NONE:
|
||||
@ -124,6 +124,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
||||
if (it->bWasShredded)
|
||||
{
|
||||
sState = "SHREDDED"; //mark drive as shreded previously, overwrite if deleted
|
||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||
}
|
||||
break;
|
||||
case Drive::FROZEN:
|
||||
@ -447,18 +448,15 @@ WINDOW* TUI::createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStar
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
string TUI::calculateTimeDelta(time_t start, time_t end)
|
||||
string TUI::formatTimeDuration(time_t u32Duration)
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
||||
int hr=(int)((end - start)/3600);
|
||||
int min=((int)((end - start)/60))%60;
|
||||
int sec=(int)((end - start)%60);
|
||||
|
||||
int hr=(int)((u32Duration)/3600);
|
||||
int min=((int)((u32Duration)/60))%60;
|
||||
int sec=(int)((u32Duration)%60);
|
||||
char s[25];
|
||||
sprintf(s, "%02d:%02d:%02d", hr, min, sec);
|
||||
out << s;
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user