Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/touch/touch.c
| Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | if (fstatat(AT_FDCWD, *argv, &sb, atflag) != 0) { | ||||
| rval = 1; | rval = 1; | ||||
| warn("%s", *argv); | warn("%s", *argv); | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (!cflag) { | if (!cflag) { | ||||
| /* Create the file. */ | /* Create the file. */ | ||||
| fd = open(*argv, | fd = open(*argv, | ||||
| O_WRONLY | O_CREAT, DEFFILEMODE); | O_WRONLY | O_CREAT, DEFFILEMODE); | ||||
| if (fd == -1) { | if (fd < 0 || fstat(fd, &sb) < 0) { | ||||
| rval = 1; | rval = 1; | ||||
| warn("%s", *argv); | warn("%s", *argv); | ||||
| if (fd >= 0) | |||||
| (void)close(fd); | |||||
| continue; | continue; | ||||
| } | } | ||||
| if (fstat(fd, &sb) < 0) { | (void)close(fd); | ||||
| warn("%s", *argv); | |||||
| rval = 1; | |||||
| } | |||||
| if (close(fd) < 0) { | |||||
| warn("%s", *argv); | |||||
| rval = 1; | |||||
| } | |||||
| /* If using the current time, we're done. */ | /* If using the current time, we're done. */ | ||||
| if (!timeset) | if (!timeset) | ||||
| continue; | continue; | ||||
| } else | } else | ||||
| continue; | continue; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 221 Lines • Show Last 20 Lines | |||||