[gvfs] admin: simplify code to set new display name



commit da423fd9a30b48078708cae5cff8bdbe4a768e85
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Mar 27 10:09:31 2016 -0700

    admin: simplify code to set new display name
    
    We can use the return value of g_file_set_display_name().

 daemon/gvfsbackendadmin.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/daemon/gvfsbackendadmin.c b/daemon/gvfsbackendadmin.c
index a767595..39a4b9e 100644
--- a/daemon/gvfsbackendadmin.c
+++ b/daemon/gvfsbackendadmin.c
@@ -671,25 +671,23 @@ do_set_display_name (GVfsBackend *backend,
   GVfsBackendAdmin *self = G_VFS_BACKEND_ADMIN (backend);
   GVfsJob *job = G_VFS_JOB (display_name_job);
   GError *error = NULL;
-  GFile *file;
-  char *dirname, *new_path;
+  GFile *file, *new_file;
+  char *new_path;
 
   if (!check_permission (self, job))
     return;
 
   file = g_file_new_for_path (filename);
-  g_file_set_display_name (file, display_name, job->cancellable, &error);
+  new_file = g_file_set_display_name (file, display_name, job->cancellable, &error);
   g_object_unref (file);
 
   if (error != NULL)
     goto out;
 
-  dirname = g_path_get_dirname (filename);
-  new_path = g_build_filename (dirname, display_name, NULL);
-
+  new_path = g_file_get_path (new_file);
   g_vfs_job_set_display_name_set_new_path (display_name_job, new_path);
-  g_free (dirname);
   g_free (new_path);
+  g_object_unref (new_file);
 
  out:
   complete_job (job, error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]