22 lines
642 B
TypeScript
22 lines
642 B
TypeScript
function cp(args:Array<string>, curdir:any):string {
|
|
var buf = "";
|
|
if(args.length == 2) {
|
|
if (curdir[args[0]] != undefined) {
|
|
if (typeof curdir[args[0]] == "string") {
|
|
curdir[args[1]] = curdir[args[0]].slice(0);
|
|
buf += "File " + args[0] + " copied to " + args[1] + "\n";
|
|
}
|
|
else {
|
|
buf += "Error: " + args[0] + " is not a file\n";
|
|
}
|
|
}
|
|
else {
|
|
buf += "Error: " + args[0] + " does not exist\n";
|
|
}
|
|
}
|
|
else {
|
|
buf += "Wrong number of arguments.\n";
|
|
}
|
|
return buf;
|
|
}
|
|
export { cp }; |