-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove.cpp
33 lines (28 loc) · 1.05 KB
/
move.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
/********************************************************************************/
/* Name: Priyendu Mori */
/* Roll no: 2018201103 */
/********************************************************************************/
#include "header.h"
#include "macro.h"
/*
this function moves files and directories
using copy and delete commands implementation
*/
void moveContent(vector<string> arguments){
copyContent(arguments);
string destination=arguments[arguments.size()-1];
arguments.erase(arguments.begin()+0);
arguments.erase(arguments.begin()+arguments.size()-1);
destination=getWholePath(destination);
for(int i=0;i<arguments.size();i++){
string path=getWholePath(arguments[i]);
struct stat stat_dir, stat_entry;
stat(path.c_str(), &stat_dir);
if (S_ISDIR(stat_dir.st_mode) == 0) {
remove(path.c_str());
}
else{
deleteHelper(path);
}
}
}