-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmovecommand.cpp
48 lines (43 loc) · 1.35 KB
/
movecommand.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
48
/************************************************************************
** RollNo:2018201033 Name : Darshan Kansagara **
************************************************************************/
//**********************************************************************
// Header file Included
//**********************************************************************
#include "myheader.h"
//**********************************************************************
// This Function moves file/folder to destination path
//**********************************************************************
void movecommand(vector<string> list)
{
unsigned int len = list.size();
if(len < 3)
{
showError("Less number of Argument in move command !!!");
}
else{
for(unsigned int i=1;i<len-1;i++)
{
string newData = list[i];
string name = getFileNameFromPath(list[i]);
//cout<<"\nfilename : "<<name;
string destpath= list[len-1];
destpath =destpath + "/" + name;
char *des = new char[destpath.length() + 1];
strcpy(des, destpath.c_str());
//cout<<"\ndespath in copy : "<<des<<endl;
char *path = new char[newData.length() + 1];
strcpy(path, newData.c_str());
if(isdirectory(path))
{
copydirectory(path,des);
removeSingleDirectory(path);
}
else
{
copyfile(path,des);
removeSingleFile(path);
}
}
}
}