-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcp.c
More file actions
44 lines (36 loc) · 914 Bytes
/
Copy pathcp.c
File metadata and controls
44 lines (36 loc) · 914 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
#include "common.h"
extern BuiltinCmd blt[MAX_BUILTIN_FUNC_NUM];
int cp(int * retc, char ** retv, const int argc, const char ** argv) {
char ch;
if(retc)
*retc = 0;
if(argc == 0)
return 1;
/*int cmdIdx = findBuiltinCmd(argv[0]);
if(cmdIdx < 0) {
printf("command: %s, non-builtin command\n", argv[0]);
return 0;
}
printf("command: %s, builtin command\n %s\n", argv[0], blt[cmdIdx].desc);
/** Add your man function here */
FILE *fp1,*fp2;
fp1=fopen(argv[0],"r+");
fp2=fopen(argv[1],"w+");
while((ch=fgetc(fp1))!=EOF){
fputc(ch,fp2);
}
fclose(fp1);
fclose(fp2);
return 0;
}
int cpAddBuiltin(){
BuiltinCmd x;
strcpy(x.name, "cp");
strcpy(x.desc, "Copy.");
x.hasAction = false;
x.func = &cp;
x.optNum = 0;
memset(x.opt, 0, sizeof(x.opt));
addBuiltinCmd(&x);
return 0;
}