close(ifd);
if (!to_stdout) {
- /* Copy modes, times, ownership, and remove the input file */
+ /* Copy modes, times, and ownership */
copy_stat(&istat);
if (close(ofd))
write_error();
+ remove_ofname = 0;
+
+ /* It's now safe to remove the input file: */
+ if (xunlink (ifname)) {
+ int e = errno;
+ WARN((stderr, "%s: ", progname));
+ if (!quiet) {
+ errno = e;
+ perror(ifname);
+ }
+ }
}
if (method == -1) {
if (!to_stdout) xunlink (ofname);
#ifndef NO_CHOWN
fchown(ofd, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */
#endif
- remove_ofname = 0;
- /* It's now safe to remove the input file: */
- if (xunlink (ifname)) {
- int e = errno;
- WARN((stderr, "%s: ", progname));
- if (!quiet) {
- errno = e;
- perror(ifname);
- }
- }
}
#if ! NO_DIR