Deleted Added
full compact
touch.c (47042) touch.c (48566)
1/*
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 115 unchanged lines hidden (view full) ---

124 if (!timeset)
125 tv[1] = tv[0];
126
127 if (*argv == NULL)
128 usage();
129
130 for (rval = 0; *argv; ++argv) {
131 /* See if the file exists. */
1/*
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 115 unchanged lines hidden (view full) ---

124 if (!timeset)
125 tv[1] = tv[0];
126
127 if (*argv == NULL)
128 usage();
129
130 for (rval = 0; *argv; ++argv) {
131 /* See if the file exists. */
132 if (stat(*argv, &sb))
132 if (stat(*argv, &sb)) {
133 if (!cflag) {
134 /* Create the file. */
135 fd = open(*argv,
136 O_WRONLY | O_CREAT, DEFFILEMODE);
137 if (fd == -1 || fstat(fd, &sb) || close(fd)) {
138 rval = 1;
139 warn("%s", *argv);
140 continue;
141 }
142
143 /* If using the current time, we're done. */
144 if (!timeset)
145 continue;
146 } else
147 continue;
133 if (!cflag) {
134 /* Create the file. */
135 fd = open(*argv,
136 O_WRONLY | O_CREAT, DEFFILEMODE);
137 if (fd == -1 || fstat(fd, &sb) || close(fd)) {
138 rval = 1;
139 warn("%s", *argv);
140 continue;
141 }
142
143 /* If using the current time, we're done. */
144 if (!timeset)
145 continue;
146 } else
147 continue;
148 }
148
149 if (!aflag)
150 TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec);
151 if (!mflag)
152 TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
153
154 /* Try utimes(2). */
155 if (!utimes(*argv, tv))

--- 193 unchanged lines hidden ---
149
150 if (!aflag)
151 TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec);
152 if (!mflag)
153 TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
154
155 /* Try utimes(2). */
156 if (!utimes(*argv, tv))

--- 193 unchanged lines hidden ---