⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mycopy.c

📁 在linux下使用c语言编写的一个文件拷贝的源码
💻 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 + -