delete task
This commit is contained in:
parent
ec300d7c75
commit
a2a18bbc34
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @file delete.h
|
||||
* @brief delete drive
|
||||
* @author hendrik schutter
|
||||
* @date 23.08.2020
|
||||
*/
|
||||
|
||||
#ifndef DELETE_H_
|
||||
#define DELETE_H_
|
||||
|
||||
#include "reHDD.h"
|
||||
|
||||
class Delete
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
static void deleteDrive(Drive* drive);
|
||||
|
||||
private:
|
||||
Delete(void);
|
||||
|
||||
};
|
||||
|
||||
#endif // DELETE_H_
|
|
@ -20,7 +20,7 @@ public:
|
|||
DELETE_SELECTED,
|
||||
DELETE_ACTIVE
|
||||
} state;
|
||||
|
||||
|
||||
bool bWasShredded = false;
|
||||
bool bWasDeleteted = false;
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ using namespace std;
|
|||
#include "drive.h"
|
||||
#include "smart.h"
|
||||
#include "shred.h"
|
||||
#include "delete.h"
|
||||
#include "tui.h"
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ private:
|
|||
static string sRamUsage;
|
||||
static string sLocalTime;
|
||||
|
||||
|
||||
|
||||
WINDOW* overview;
|
||||
WINDOW* systemview;
|
||||
WINDOW* detailview;
|
||||
|
@ -59,7 +59,7 @@ private:
|
|||
static WINDOW *createSystemStats(int iXSize, int iYSize, int iYStart);
|
||||
static WINDOW *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate);
|
||||
static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, string selectedTask, string optionA, string optionB);
|
||||
|
||||
|
||||
void displaySelectedDrive(Drive drive, int stdscrX, int stdscrY);
|
||||
|
||||
};
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @file delete.cpp
|
||||
* @brief delete drive
|
||||
* @author hendrik schutter
|
||||
* @date 23.08.2020
|
||||
*/
|
||||
|
||||
#include "../include/reHDD.h"
|
||||
|
||||
/**
|
||||
* \brief delete drive with wipefs
|
||||
* \param pointer of Drive instance
|
||||
* \return void
|
||||
*/
|
||||
void Delete::deleteDrive(Drive* drive)
|
||||
|
||||
{
|
||||
size_t len = 0; //lenght of found line
|
||||
char* cLine = NULL; //found line
|
||||
|
||||
#ifndef DRYRUN
|
||||
string sCMD = ("wipefs -af ");
|
||||
sCMD.append(drive->getPath());
|
||||
#endif
|
||||
|
||||
#ifdef DRYRUN
|
||||
//cout << "dryrun for " << drive->getPath() << endl;
|
||||
string sCMD = ("echo");
|
||||
#endif
|
||||
|
||||
const char* cpComand = sCMD.c_str();
|
||||
//cout << "delete: " << cpComand << endl;
|
||||
|
||||
FILE* deleteCmdOutput = popen(cpComand, "r");
|
||||
|
||||
while ((getline(&cLine, &len, deleteCmdOutput)) != -1)
|
||||
{
|
||||
//wipefs running
|
||||
}
|
||||
fclose(deleteCmdOutput);
|
||||
}
|
|
@ -163,7 +163,7 @@ void reHDD::ThreadUserInput()
|
|||
|
||||
void reHDD::ThreadShred()
|
||||
{
|
||||
Shred::shredDrive(&vecDrives.at(i32SelectedEntry), &fdShredInformPipe[1]);
|
||||
Shred::shredDrive(&SELECTED_DRIVE, &fdShredInformPipe[1]);
|
||||
}
|
||||
|
||||
void reHDD::filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecNewDrives)
|
||||
|
@ -191,7 +191,6 @@ void reHDD::filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecN
|
|||
if(bOldDriveIsOffline == true)
|
||||
{
|
||||
//cout << "offline drive found: " << itOld->getPath() << endl;
|
||||
//TODO kill task thread if running
|
||||
itOld->state = Drive::NONE;
|
||||
}
|
||||
}
|
||||
|
@ -396,7 +395,9 @@ void reHDD::handleEnter()
|
|||
{
|
||||
SELECTED_DRIVE.state = Drive::TaskState::DELETE_ACTIVE;
|
||||
//task for drive is running --> don´t show more task options
|
||||
//TODO start deleting
|
||||
Delete::deleteDrive(&SELECTED_DRIVE); //blocking, no thread
|
||||
SELECTED_DRIVE.state = Drive::TaskState::NONE; //delete finished
|
||||
SELECTED_DRIVE.bWasDeleteted = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,7 +420,6 @@ void reHDD::handleAbort()
|
|||
{
|
||||
if(SELECTED_DRIVE.state == Drive::SHRED_ACTIVE || SELECTED_DRIVE.state == Drive::DELETE_ACTIVE )
|
||||
{
|
||||
// TODO cancle shred or delete
|
||||
SELECTED_DRIVE.state = Drive::NONE;
|
||||
//task for drive is running --> remove selection
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ void reHDD::checkShredComplete(vector <Drive>* pvecDrives)
|
|||
{
|
||||
it->bWasShredded = true; //mark this drive as shredded
|
||||
it->setTaskPercentage(0); //reset for an other shredding
|
||||
it->state = Drive::NONE; //reset for an other task#
|
||||
it->state = Drive::NONE; //reset for an other task
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue