-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmymv.cpp
More file actions
50 lines (38 loc) · 1002 Bytes
/
mymv.cpp
File metadata and controls
50 lines (38 loc) · 1002 Bytes
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
48
49
50
/*Author: Michael Giancola
*Date: 03/10/2019
*Description: This file contains the mymv utlity which moves a file from one locaton to another.
*This utlilty also supports across system platform moves as well.
**/
#include <iostream>
#include "FileManager.h"
using namespace std;
int main(int argc, char *argv[])
{
if (argc != 3)
{
cout << "Invalid number of arguments!" << endl;
return 0;
}
FileManager obj1(argv[1]);
if (obj1.getUserName() == "Destroy Me")
{
cout << obj1.getName() << ": No such file or directory" << endl;
return 0;
}
int check = obj1.rename_(argv[2]); //uses rename to move file locally
if (check != 0) //this is for if the file transfer is over two different systems (if an error occurs in the rename_ we know)
{
ofstream file{argv[2]};
if (file.bad())
{
return EIO;
}
obj1.dump(file);
obj1.remove();
file.close();
if (file.bad())
{
return EIO;
}
}
}