-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileEraser.cpp
More file actions
47 lines (43 loc) · 1.08 KB
/
fileEraser.cpp
File metadata and controls
47 lines (43 loc) · 1.08 KB
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
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <deque>
#include "ospath.h"
using namespace std;
char* curPath;
void eraseDirExecuteFile(const char *yourFile)
{
path p(yourFile);
deque<string> dirQ = p.readDir(p.getCurPath(), false);
while (!dirQ.empty())
{
string curFile = dirQ.back();
dirQ.pop_back();
if (!strcmp(curPath, curFile.c_str()) || p.isDir(curFile))
continue;
else if (!strstr(curFile.c_str(), ".") && p.isExecute(curFile.c_str()))
{
cout << "delete your exeCute file -- > " << curFile.c_str() << endl;
if (unlink(curFile.c_str()) < 0)
{
fprintf(stderr, "ulink error : %s\n", curFile.c_str());
continue;
}
}
}
}
int main(int argc , char* argv[])
{
curPath = argv[0];
#ifdef OPT
eraseDirExecuteFile(OPT);
#endif
if (argc < 2) {
eraseDirExecuteFile(getcwd(NULL, 0));
}
for (int i = 1 ; i < argc ; i++) {
eraseDirExecuteFile(*(argv+i));
}
exit(0);
}