X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=compat%2Fmingw.c;h=b98e6000062134f01a0611fb17a3fd43250f7989;hb=385cc9d8c44eb5be9d57e630129752a72c0a08c8;hp=9a8e3365827d303c6513475726113a3952fe0040;hpb=3d045897585c4b1ca0dce6bb5a33331f1b48c2bf;p=git.git diff --git a/compat/mingw.c b/compat/mingw.c index 9a8e33658..b98e60000 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -195,9 +195,10 @@ static inline time_t filetime_to_time_t(const FILETIME *ft) */ static int do_lstat(const char *file_name, struct stat *buf) { + int err; WIN32_FILE_ATTRIBUTE_DATA fdata; - if (!(errno = get_file_attr(file_name, &fdata))) { + if (!(err = get_file_attr(file_name, &fdata))) { buf->st_ino = 0; buf->st_gid = 0; buf->st_uid = 0; @@ -211,6 +212,7 @@ static int do_lstat(const char *file_name, struct stat *buf) buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime)); return 0; } + errno = err; return -1; } @@ -304,8 +306,13 @@ int mingw_utime (const char *file_name, const struct utimbuf *times) goto revert_attrs; } - time_t_to_filetime(times->modtime, &mft); - time_t_to_filetime(times->actime, &aft); + if (times) { + time_t_to_filetime(times->modtime, &mft); + time_t_to_filetime(times->actime, &aft); + } else { + GetSystemTimeAsFileTime(&mft); + aft = mft; + } if (!SetFileTime((HANDLE)_get_osfhandle(fh), NULL, &aft, &mft)) { errno = EINVAL; rc = -1; @@ -641,7 +648,7 @@ static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_on } /* - * Determines the absolute path of cmd using the the split path in path. + * Determines the absolute path of cmd using the split path in path. * If cmd contains a slash or backslash, no lookup is performed. */ static char *path_lookup(const char *cmd, char **path, int exe_only)