diff --git a/lib/vfs/utilvfs.c b/lib/vfs/utilvfs.c index 5a9fa453b..8f4e05cc9 100644 --- a/lib/vfs/utilvfs.c +++ b/lib/vfs/utilvfs.c @@ -38,6 +38,10 @@ #include #include +#if !defined (HAVE_UTIMENSAT) && defined (HAVE_UTIME_H) +#include +#endif + #include "lib/global.h" #include "lib/unixcompat.h" #include "lib/widget.h" /* message() */ @@ -372,3 +376,15 @@ vfs_get_password (const char *msg) } /* --------------------------------------------------------------------------------------------- */ + +int +vfs_utime (const char *path, mc_timesbuf_t *times) +{ +#ifdef HAVE_UTIMENSAT + return utimensat (AT_FDCWD, path, *times, AT_SYMLINK_NOFOLLOW); +#else + return utime (path, times); +#endif +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/vfs/utilvfs.h b/lib/vfs/utilvfs.h index 362bd55d1..a203b78dd 100644 --- a/lib/vfs/utilvfs.h +++ b/lib/vfs/utilvfs.h @@ -60,5 +60,8 @@ size_t vfs_parse_ls_lga_get_final_spaces (void); gboolean vfs_parse_month (const char *str, struct tm *tim); int vfs_parse_filedate (int idx, time_t * t); +int vfs_utime (const char *path, mc_timesbuf_t *times); + /*** inline functions ****************************************************************************/ + #endif diff --git a/src/vfs/local/local.c b/src/vfs/local/local.c index 88450a568..337646508 100644 --- a/src/vfs/local/local.c +++ b/src/vfs/local/local.c @@ -26,6 +26,7 @@ */ #include + #include #include #include @@ -217,16 +218,7 @@ local_fsetflags (const vfs_path_t *vpath, unsigned long flags) static int local_utime (const vfs_path_t *vpath, mc_timesbuf_t *times) { - int ret; - const char *path; - - path = vfs_path_get_last_path_str (vpath); -#ifdef HAVE_UTIMENSAT - ret = utimensat (AT_FDCWD, path, *times, AT_SYMLINK_NOFOLLOW); -#else - ret = utime (path, times); -#endif - return ret; + return vfs_utime (vfs_path_get_last_path_str (vpath), times); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/vfs/sfs/sfs.c b/src/vfs/sfs/sfs.c index c7107f5d5..e3be15f35 100644 --- a/src/vfs/sfs/sfs.c +++ b/src/vfs/sfs/sfs.c @@ -349,11 +349,7 @@ sfs_chown (const vfs_path_t *vpath, uid_t owner, gid_t group) static int sfs_utime (const vfs_path_t *vpath, mc_timesbuf_t *times) { -#ifdef HAVE_UTIMENSAT - return utimensat (AT_FDCWD, sfs_redirect (vpath), *times, 0); -#else - return utime (sfs_redirect (vpath), times); -#endif + return vfs_utime (sfs_redirect (vpath), times); } /* --------------------------------------------------------------------------------------------- */