📄 mycopy.c
字号:
#include <linux/unistd.h>#include <fcntl.h>#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <errno.h>#include <string.h>_syscall4(int , mycopy, int, SourceFile, int, DestFile, char *, Buffer, int, BUFFER_SIZE);int main(int argc, char **argv){ int SourceFile, DestFile; int status; char desc; int BUFFER_SIZE=1024; char Buffer[BUFFER_SIZE]; /* Not Enough Parameters */ if (argc != 3) { printf("Usage Errot!:%s fromfile tofile\n\a", argv[0]); exit(1); } /* Source File Not Exit */ if (status = access(argv[1], F_OK)) { printf("The Source File Not Exit.\n"); exit(1); } /* Destination File Exit */ if ((status = access(argv[2], F_OK)) == 0) { printf("The Destination File Exit.Overwrite?(y/n)\n"); desc = getchar(); while (desc != 'n' && desc != 'y') { printf("The Destination File Exit.Overwrite?(y/n)\n"); desc = getchar(); } if (desc == 'n') exit(0); } /* Open the Source File */ if ((SourceFile = open(argv[1], O_RDONLY)) == -1) { printf("Open %s Error:%s\n", argv[1], strerror(errno)); exit(1); } /* Open the Destination File */ if ((DestFile = open(argv[2], O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) == -1) { printf("Open %s Error:%s\n", argv[2], strerror(errno)); exit(1); } mycopy(SourceFile, DestFile, Buffer, BUFFER_SIZE); close(SourceFile); close(DestFile); exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -