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.
This commit is contained in:
parent
6e1b469ee2
commit
b34454d067
2 changed files with 29 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
2013-08-24 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* w32.c (fdutimens): Call 'utime', which is implemented on w32.c
|
||||
to handle directories, rather than '_utime' which doesn't.
|
||||
(Bug#15176)
|
||||
|
||||
2013-08-24 Jan Djärv <jan.h.d@swipnet.se>
|
||||
|
||||
* gtkutil.c (x_wm_set_size_hint): Don't set hints when maximized
|
||||
|
|
29
src/w32.c
29
src/w32.c
|
@ -2503,8 +2503,6 @@ gettimeofday (struct timeval *__restrict tv, struct timezone *__restrict tz)
|
|||
int
|
||||
fdutimens (int fd, char const *file, struct timespec const timespec[2])
|
||||
{
|
||||
struct _utimbuf ut;
|
||||
|
||||
if (!timespec)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
|
@ -2515,12 +2513,28 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
|
|||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
ut.actime = timespec[0].tv_sec;
|
||||
ut.modtime = timespec[1].tv_sec;
|
||||
/* _futime's prototype defines 2nd arg as having the type 'struct
|
||||
_utimbuf', while utime needs to accept 'struct utimbuf' for
|
||||
compatibility with Posix. So we need to use 2 different (but
|
||||
equivalent) types to avoid compiler warnings, sigh. */
|
||||
if (fd >= 0)
|
||||
return _futime (fd, &ut);
|
||||
{
|
||||
struct _utimbuf _ut;
|
||||
|
||||
_ut.actime = timespec[0].tv_sec;
|
||||
_ut.modtime = timespec[1].tv_sec;
|
||||
return _futime (fd, &_ut);
|
||||
}
|
||||
else
|
||||
return _utime (file, &ut);
|
||||
{
|
||||
struct utimbuf ut;
|
||||
|
||||
ut.actime = timespec[0].tv_sec;
|
||||
ut.modtime = timespec[1].tv_sec;
|
||||
/* Call 'utime', which is implemented below, not the MS library
|
||||
function, which fails on directories. */
|
||||
return utime (file, &ut);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -4501,6 +4515,9 @@ fstat (int desc, struct stat * buf)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* A version of 'utime' which handles directories as well as
|
||||
files. */
|
||||
|
||||
int
|
||||
utime (const char *name, struct utimbuf *times)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue