version 1.275, 2021/10/24 21:24:16 |
version 1.276, 2023/08/11 04:48:14 |
|
|
cvs_file_copy(const char *from, const char *to) |
cvs_file_copy(const char *from, const char *to) |
{ |
{ |
struct stat st; |
struct stat st; |
struct timeval tv[2]; |
struct timespec ts[2]; |
time_t atime, mtime; |
|
int src, dst, ret; |
int src, dst, ret; |
|
|
ret = 0; |
ret = 0; |
|
|
if (fstat(src, &st) == -1) |
if (fstat(src, &st) == -1) |
fatal("cvs_file_copy: `%s': %s", from, strerror(errno)); |
fatal("cvs_file_copy: `%s': %s", from, strerror(errno)); |
|
|
atime = st.st_atimespec.tv_sec; |
|
mtime = st.st_mtimespec.tv_sec; |
|
|
|
if (S_ISREG(st.st_mode)) { |
if (S_ISREG(st.st_mode)) { |
char *p; |
char *p; |
int saved_errno; |
int saved_errno; |
|
|
|
|
(void)munmap(p, st.st_size); |
(void)munmap(p, st.st_size); |
|
|
tv[0].tv_sec = atime; |
ts[0] = st.st_atim; |
tv[1].tv_sec = mtime; |
ts[1] = st.st_mtim; |
|
|
if (futimes(dst, tv) == -1) { |
if (futimens(dst, ts) == -1) { |
saved_errno = errno; |
saved_errno = errno; |
(void)unlink(to); |
(void)unlink(to); |
fatal("cvs_file_copy: futimes: %s", |
fatal("cvs_file_copy: futimes: %s", |