diff options
| author | Eli Zaretskii | 2013-08-24 13:15:01 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-08-24 13:15:01 +0300 |
| commit | b34454d067efe26983f32ee6dc725d5122de58f4 (patch) | |
| tree | 99acaa53c69ec7dde6d1a4c382feca106af8f7d4 /src | |
| parent | 6e1b469ee2c44797e9f7922366d069e0f924cc63 (diff) | |
| download | emacs-b34454d067efe26983f32ee6dc725d5122de58f4.tar.gz emacs-b34454d067efe26983f32ee6dc725d5122de58f4.zip | |
Fix bug #15176 with setting directory times on MS-Windows.
src/w32.c (fdutimens): Call 'utime', which is implemented on w32.c
to handle directories, rather than '_utime' which doesn't.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/w32.c | 29 |
2 files changed, 29 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8e5eedd445c..2bb41071fd6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-08-24 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * w32.c (fdutimens): Call 'utime', which is implemented on w32.c | ||
| 4 | to handle directories, rather than '_utime' which doesn't. | ||
| 5 | (Bug#15176) | ||
| 6 | |||
| 1 | 2013-08-24 Jan Djärv <jan.h.d@swipnet.se> | 7 | 2013-08-24 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 8 | ||
| 3 | * gtkutil.c (x_wm_set_size_hint): Don't set hints when maximized | 9 | * gtkutil.c (x_wm_set_size_hint): Don't set hints when maximized |
| @@ -2503,8 +2503,6 @@ gettimeofday (struct timeval *__restrict tv, struct timezone *__restrict tz) | |||
| 2503 | int | 2503 | int |
| 2504 | fdutimens (int fd, char const *file, struct timespec const timespec[2]) | 2504 | fdutimens (int fd, char const *file, struct timespec const timespec[2]) |
| 2505 | { | 2505 | { |
| 2506 | struct _utimbuf ut; | ||
| 2507 | |||
| 2508 | if (!timespec) | 2506 | if (!timespec) |
| 2509 | { | 2507 | { |
| 2510 | errno = ENOSYS; | 2508 | errno = ENOSYS; |
| @@ -2515,12 +2513,28 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2]) | |||
| 2515 | errno = EBADF; | 2513 | errno = EBADF; |
| 2516 | return -1; | 2514 | return -1; |
| 2517 | } | 2515 | } |
| 2518 | ut.actime = timespec[0].tv_sec; | 2516 | /* _futime's prototype defines 2nd arg as having the type 'struct |
| 2519 | ut.modtime = timespec[1].tv_sec; | 2517 | _utimbuf', while utime needs to accept 'struct utimbuf' for |
| 2518 | compatibility with Posix. So we need to use 2 different (but | ||
| 2519 | equivalent) types to avoid compiler warnings, sigh. */ | ||
| 2520 | if (fd >= 0) | 2520 | if (fd >= 0) |
| 2521 | return _futime (fd, &ut); | 2521 | { |
| 2522 | struct _utimbuf _ut; | ||
| 2523 | |||
| 2524 | _ut.actime = timespec[0].tv_sec; | ||
| 2525 | _ut.modtime = timespec[1].tv_sec; | ||
| 2526 | return _futime (fd, &_ut); | ||
| 2527 | } | ||
| 2522 | else | 2528 | else |
| 2523 | return _utime (file, &ut); | 2529 | { |
| 2530 | struct utimbuf ut; | ||
| 2531 | |||
| 2532 | ut.actime = timespec[0].tv_sec; | ||
| 2533 | ut.modtime = timespec[1].tv_sec; | ||
| 2534 | /* Call 'utime', which is implemented below, not the MS library | ||
| 2535 | function, which fails on directories. */ | ||
| 2536 | return utime (file, &ut); | ||
| 2537 | } | ||
| 2524 | } | 2538 | } |
| 2525 | 2539 | ||
| 2526 | 2540 | ||
| @@ -4501,6 +4515,9 @@ fstat (int desc, struct stat * buf) | |||
| 4501 | return 0; | 4515 | return 0; |
| 4502 | } | 4516 | } |
| 4503 | 4517 | ||
| 4518 | /* A version of 'utime' which handles directories as well as | ||
| 4519 | files. */ | ||
| 4520 | |||
| 4504 | int | 4521 | int |
| 4505 | utime (const char *name, struct utimbuf *times) | 4522 | utime (const char *name, struct utimbuf *times) |
| 4506 | { | 4523 | { |