updated: [master] [c8e8f01] utilvfs: concentrate timesbuf handling in one place

2 views
Skip to first unread message

Yury V. Zaytsev

unread,
Jul 28, 2024, 4:01:35 AM7/28/24
to mc-co...@googlegroups.com
The following commit has been merged in the master branch:
commit c8e8f01fafd1103f1a4791568704a608f685d7a5
Author: Yury V. Zaytsev <yu...@shurup.com>
Date: Fri May 31 21:02:00 2024 +0200

utilvfs: concentrate timesbuf handling in one place

Signed-off-by: Yury V. Zaytsev <yu...@shurup.com>

diff --git a/lib/vfs/utilvfs.c b/lib/vfs/utilvfs.c
index f9a8398..b322d63 100644
--- a/lib/vfs/utilvfs.c
+++ b/lib/vfs/utilvfs.c
@@ -406,3 +406,17 @@ vfs_get_timespecs_from_timesbuf (mc_timesbuf_t *times, mc_timespec_t *atime, mc_
}

/* --------------------------------------------------------------------------------------------- */
+
+void
+vfs_get_timesbuf_from_stat (const struct stat *sb, mc_timesbuf_t *times)
+{
+#ifdef HAVE_UTIMENSAT
+ (*times)[0] = sb->st_atim;
+ (*times)[1] = sb->st_mtim;
+#else
+ times->actime = sb->st_atime;
+ times->modtime = sb->st_mtime;
+#endif
+}
+
+/* --------------------------------------------------------------------------------------------- */
diff --git a/lib/vfs/utilvfs.h b/lib/vfs/utilvfs.h
index 49e6bc4..4f4772d 100644
--- a/lib/vfs/utilvfs.h
+++ b/lib/vfs/utilvfs.h
@@ -63,6 +63,7 @@ int vfs_parse_filedate (int idx, time_t * t);
int vfs_utime (const char *path, mc_timesbuf_t *times);
void vfs_get_timespecs_from_timesbuf (mc_timesbuf_t *times, mc_timespec_t *atime,
mc_timespec_t *mtime);
+void vfs_get_timesbuf_from_stat (const struct stat *sb, mc_timesbuf_t *times);

/*** inline functions ****************************************************************************/

diff --git a/src/filemanager/file.c b/src/filemanager/file.c
index f7f0796..8ded73c 100644
--- a/src/filemanager/file.c
+++ b/src/filemanager/file.c
@@ -67,6 +67,7 @@
#include "lib/strutil.h"
#include "lib/util.h"
#include "lib/vfs/vfs.h"
+#include "lib/vfs/utilvfs.h"
#include "lib/widget.h"

#include "src/setup.h"
@@ -928,20 +929,6 @@ check_same_file (const char *a, const struct stat *ast, const char *b, const str
}

/* --------------------------------------------------------------------------------------------- */
-
-static void
-get_times (const struct stat *sb, mc_timesbuf_t *times)
-{
-#ifdef HAVE_UTIMENSAT
- (*times)[0] = sb->st_atim;
- (*times)[1] = sb->st_mtim;
-#else
- times->actime = sb->st_atime;
- times->modtime = sb->st_mtime;
-#endif
-}
-
-/* --------------------------------------------------------------------------------------------- */
/* {{{ Query/status report routines */

static FileProgressStatus
@@ -1297,7 +1284,7 @@ move_file_file (const WPanel *panel, file_op_total_context_t *tctx, file_op_cont
{
mc_timesbuf_t times;

- get_times (&src_stat, &times);
+ vfs_get_timesbuf_from_stat (&src_stat, &times);
mc_utime (dst_vpath, &times);
}
goto retry_src_remove;
@@ -2375,7 +2362,7 @@ copy_file_file (file_op_total_context_t *tctx, file_op_context_t *ctx,
}
}

- get_times (&src_stat, &times);
+ vfs_get_timesbuf_from_stat (&src_stat, &times);

if (!ctx->do_append)
{
@@ -3232,7 +3219,7 @@ copy_dir_dir (file_op_total_context_t *tctx, file_op_context_t *ctx, const char
if (attrs_ok)
mc_fsetflags (dst_vpath, attrs);

- get_times (&src_stat, &times);
+ vfs_get_timesbuf_from_stat (&src_stat, &times);
mc_utime (dst_vpath, &times);
}
else

--
Midnight Commander Development
Reply all
Reply to author
Forward
0 new messages