reHDD/src/delete.cpp

43 lines
858 B
C++
Raw Permalink Normal View History

2020-08-23 11:04:10 +02:00
/**
* @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
*/
2024-04-24 22:31:09 +02:00
void Delete::deleteDrive(Drive *drive)
2020-08-23 11:04:10 +02:00
{
2024-04-24 22:31:09 +02:00
size_t len = 0; // lenght of found line
char *cLine = NULL; // found line
2020-08-23 11:04:10 +02:00
#ifndef DRYRUN
string sCMD = ("wipefs -af ");
sCMD.append(drive->getPath());
2020-09-18 14:42:45 +02:00
sCMD.append("*");
2020-08-23 11:04:10 +02:00
#endif
#ifdef DRYRUN
2024-04-24 22:31:09 +02:00
// cout << "dryrun for " << drive->getPath() << endl;
2020-08-23 11:04:10 +02:00
string sCMD = ("echo");
#endif
2024-04-24 22:31:09 +02:00
const char *cpComand = sCMD.c_str();
// cout << "delete: " << cpComand << endl;
2020-08-23 11:04:10 +02:00
2024-04-24 22:31:09 +02:00
FILE *deleteCmdOutput = popen(cpComand, "r");
2020-08-23 11:04:10 +02:00
while ((getline(&cLine, &len, deleteCmdOutput)) != -1)
2024-04-24 22:31:09 +02:00
{
// wipefs running
}
2022-01-26 15:44:32 +01:00
pclose(deleteCmdOutput);
2020-08-23 11:04:10 +02:00
}