summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2019-09-16 17:06:27 +0200
committerOndrej Holy <oholy@redhat.com>2019-09-20 11:53:57 +0000
commit643c8212aa106d46da1c231d8d1032390b0f39a1 (patch)
treea8ab0037169238ea14e4b41390c0675c54e214f2 /daemon
parent82d5b6b821773c5ab17f37538dfd1834798d1922 (diff)
downloadgvfs-643c8212aa106d46da1c231d8d1032390b0f39a1.tar.gz
trash: Replace usage of deprecated GTimeVal by GDateTime
GTimeVal is deprecated. Let's replace it by GDateTime in order to prevent the deprecation warnings.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/trashlib/trashdir.c39
1 files 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,