[gvfs/wip/oholy/gtimeval-gdatetime: 9/11] trash: Replace usage of deprecated GTimeVal by GDateTime
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/wip/oholy/gtimeval-gdatetime: 9/11] trash: Replace usage of deprecated GTimeVal by GDateTime
- Date: Fri, 20 Sep 2019 11:54:46 +0000 (UTC)
commit 643c8212aa106d46da1c231d8d1032390b0f39a1
Author: Ondrej Holy <oholy redhat com>
Date: Mon Sep 16 17:06:27 2019 +0200
trash: Replace usage of deprecated GTimeVal by GDateTime
GTimeVal is deprecated. Let's replace it by GDateTime in order to
prevent the deprecation warnings.
daemon/trashlib/trashdir.c | 39 +++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/daemon/trashlib/trashdir.c b/daemon/trashlib/trashdir.c
index 7875b007..c470d3bd 100644
--- a/daemon/trashlib/trashdir.c
+++ b/daemon/trashlib/trashdir.c
@@ -21,7 +21,7 @@ struct OPAQUE_TYPE__TrashDir
GFile *directory;
GFile *topdir;
gboolean is_homedir;
- GTimeVal mtime;
+ GDateTime *mtime;
DirWatch *watch;
GFileMonitor *monitor;
@@ -49,24 +49,22 @@ compare_basename (gconstpointer a,
return result;
}
-static void
-trash_dir_query_mtime (TrashDir *dir, GTimeVal *mtime)
+static GDateTime *
+trash_dir_query_mtime (TrashDir *dir)
{
GFileInfo *info;
+ GDateTime *datetime = NULL;
info = g_file_query_info (dir->directory, G_FILE_ATTRIBUTE_TIME_MODIFIED ","
G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC,
G_FILE_QUERY_INFO_NONE, NULL, NULL);
if (info)
{
- g_file_info_get_modification_time (info, mtime);
+ datetime = g_file_info_get_modification_date_time (info);
g_object_unref (info);
}
- else
- {
- mtime->tv_sec = 0;
- mtime->tv_usec = 0;
- }
+
+ return datetime;
}
static void
@@ -127,7 +125,8 @@ trash_dir_enumerate (TrashDir *dir)
GFileEnumerator *enumerator;
GSList *files = NULL;
- trash_dir_query_mtime (dir, &dir->mtime);
+ g_clear_pointer (&dir->mtime, g_date_time_unref);
+ dir->mtime = trash_dir_query_mtime (dir);
enumerator = g_file_enumerate_children (dir->directory,
G_FILE_ATTRIBUTE_STANDARD_NAME,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
@@ -231,6 +230,7 @@ trash_dir_destroyed (gpointer user_data)
g_assert (dir->monitor != NULL);
g_object_unref (dir->monitor);
dir->monitor = NULL;
+ g_clear_pointer (&dir->mtime, g_date_time_unref);
trash_dir_empty (dir);
}
@@ -323,15 +323,21 @@ dir_exists (GFile *directory,
static gboolean
trash_dir_is_dirty (TrashDir *dir)
{
- GTimeVal mtime;
+ GDateTime *mtime;
+ gboolean retval = TRUE;
+
+ if (dir->mtime == NULL)
+ return TRUE;
- trash_dir_query_mtime (dir, &mtime);
+ mtime = trash_dir_query_mtime (dir);
+ if (mtime == NULL)
+ return TRUE;
- if (mtime.tv_sec == dir->mtime.tv_sec &&
- mtime.tv_usec == dir->mtime.tv_usec)
- return FALSE;
+ if (g_date_time_equal (mtime, dir->mtime))
+ retval = FALSE;
+ g_date_time_unref (mtime);
- return TRUE;
+ return retval;
}
void
@@ -376,6 +382,7 @@ trash_dir_new (TrashRoot *root,
dir->directory = g_file_get_child (dir->topdir, rel);
dir->monitor = NULL;
dir->is_homedir = is_homedir;
+ dir->mtime = NULL;
if (watching)
dir->watch = dir_watch_new (dir->directory,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]