[gnome-commander] gnome_cmd_dir_update_mtime: use GIO for retrieving the modification time
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] gnome_cmd_dir_update_mtime: use GIO for retrieving the modification time
- Date: Sun, 16 May 2021 15:07:02 +0000 (UTC)
commit 684396f2d1f74287e9401b4dbed91e056fbf648a
Author: Uwe Scholz <u scholz83 gmx de>
Date: Sun May 16 17:04:54 2021 +0200
gnome_cmd_dir_update_mtime: use GIO for retrieving the modification time
src/gnome-cmd-dir.cc | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/gnome-cmd-dir.cc b/src/gnome-cmd-dir.cc
index dbc13000..2a45cb67 100644
--- a/src/gnome-cmd-dir.cc
+++ b/src/gnome-cmd-dir.cc
@@ -964,20 +964,23 @@ gboolean gnome_cmd_dir_update_mtime (GnomeCmdDir *dir)
// assume cache is updated
gboolean returnValue = FALSE;
- GnomeVFSURI *uri = gnome_cmd_dir_get_uri (dir);
- GnomeVFSFileInfo *info = gnome_vfs_file_info_new ();
- GnomeVFSResult res = gnome_vfs_get_file_info_uri (uri, info, (GnomeVFSFileInfoOptions)
- (GNOME_VFS_FILE_INFO_FOLLOW_LINKS |
GNOME_VFS_FILE_INFO_NAME_ONLY));
- if (res != GNOME_VFS_OK || GNOME_CMD_FILE(dir)->info->mtime != info->mtime)
+
+ auto uri = gnome_cmd_file_get_uri_str(GNOME_CMD_FILE(dir));
+ auto tempGFile = g_file_new_for_uri(uri);
+ auto gFileInfoCurrent = g_file_query_info(tempGFile, G_FILE_ATTRIBUTE_TIME_MODIFIED,
G_FILE_QUERY_INFO_NONE, nullptr, nullptr);
+ auto currentMTime = g_file_info_get_modification_date_time(gFileInfoCurrent);
+
+ auto cachedMTime = g_file_info_get_modification_date_time(GNOME_CMD_FILE(dir)->gFileInfo);
+ g_free(uri);
+ g_object_unref(gFileInfoCurrent);
+
+ if (currentMTime && cachedMTime && !g_date_time_compare(cachedMTime, currentMTime))
{
// cache is not up-to-date
- GNOME_CMD_FILE (dir)->info->mtime = info->mtime;
+ g_file_info_set_modification_date_time(GNOME_CMD_FILE (dir)->gFileInfo, currentMTime);
returnValue = TRUE;
}
- gnome_vfs_file_info_unref (info);
- gnome_vfs_uri_unref (uri);
-
// after this function we are sure dir's mtime is up-to-date
dir->priv->needs_mtime_update = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]