-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyrm.cpp
47 lines (38 loc) · 988 Bytes
/
myrm.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
39
40
41
42
43
44
45
46
47
/*Author: Michael Giancola
*Date: 03/10/2019
*Description: This file contains the myrm utility and removes the specified file or files that the user wants
*deleted from the system.
**/
#include <iostream>
#include "FileManager.h"
using namespace std;
int main(int argc, char *argv[])
{
if (argc < 2)
{
cout << "You have entered an incorrect amount of arguments" << endl;
return 0;
}
int i = 1;
while (i < argc)
{
FileManager obj(argv[i]);
obj.remove(); //remove function unlinks the file from the system
if (obj.getUserName() == "Destroy Me")
{
cout << obj.getName() << ": No such file or directory" << endl;
i++;
continue;
}
i++;
}
if (argc == 2) //if one file is being removed
{
cout << "The requested file have been removed." << endl;
return 0;
}
else //if multiple files are being removed
{
cout << "The requested files have been removed." << endl;
}
}