touch.c

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 41 行

C
41
字号
#ifndef lintstatic char *sccsid = "@(#)touch.c	4.1      (ULTRIX)        7/2/90";#endif lint#ifdef KERNEL#include "../h/types.h"#include "../h/stat.h"#else KERNEL#include <sys/types.h>#include <sys/stat.h>#endif KERNELmain(argc, argv)	int argc;	char **argv;{	argc--, argv++;	while (argc > 0) {		struct stat stb; int c, f;		if (stat(*argv, &stb) < 0)			goto bad;		if (chmod(*argv, stb.st_mode | 0200) < 0)			goto bad;		f = open(*argv, 2);		if (f < 0)			goto bad;		lseek(f, 0, 0);		read(f, &c, 1);		lseek(f, 0, 0);		write(f, &c, 1);		close(f);		chmod(*argv, stb.st_mode);		argc--, argv++;		continue;bad:		perror(*argv);		argc--, argv++;		continue;	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?