-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.cpp
38 lines (35 loc) · 800 Bytes
/
delete.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <cstdio>
#include <fstream>
#include <unistd.h>
#include <ctime>
#include <ios>
#include <sys/stat.h>
using namespace std;
const std::string currentDateTime() {
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct);
return buf;
}
int main(int argc, char *argv[])
{
if(argc>1)
{
ofstream outf("/home/gaurav/Desktop/command.txt",ios::out|ios::app);
for(int i=1;i<argc;i++)
{
char cwd[1024];
getcwd(cwd, sizeof(cwd));
outf<<"2\n"<<cwd<<"/"<<argv[i]<<"\n";
}
outf.close();
printf("\nfile deleted!\n");
}
else
{
printf("Filename missing!\n");
}
return 0;
}