From c2ee9b2c760a7dfaad2ac785dd93b1bd163c00cb Mon Sep 17 00:00:00 2001 From: Benedikt Meurer <benny@xfce.org> Date: Sun, 26 Jun 2005 13:00:38 +0000 Subject: [PATCH] 2005-06-26 Benedikt Meurer <benny@xfce.org> * thunar-vfs/thunar-vfs-info.{c,h}: Do not automatically determine the link target for ThunarVfsInfo objects. Instead, we'll add a method to ThunarVfsInfo later, so modules can do this on-demand. This speeds up loading directories with lots of symlinks within. * TODO: Remove the ThunarVfsInfo symlink item. (Old svn revision: 16358) --- ChangeLog | 8 ++++++++ TODO | 3 --- thunar-vfs/thunar-vfs-info.c | 37 ++---------------------------------- thunar-vfs/thunar-vfs-info.h | 16 ++-------------- 4 files changed, 12 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 10d8c6d76..3b9ab6899 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-06-26 Benedikt Meurer <benny@xfce.org> + + * thunar-vfs/thunar-vfs-info.{c,h}: Do not automatically determine the + link target for ThunarVfsInfo objects. Instead, we'll add a method + to ThunarVfsInfo later, so modules can do this on-demand. This speeds + up loading directories with lots of symlinks within. + * TODO: Remove the ThunarVfsInfo symlink item. + 2005-06-26 Benedikt Meurer <benny@xfce.org> * thunar-vfs/thunar-vfs-uri.{c,h}: Don't use a GObject for the diff --git a/TODO b/TODO index 0b8630b81..50f844f39 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,6 @@ Important for Thunar 1.0 ======================== - - Do NOT automatically determine the link target for ThunarVfsInfo objects. - Instead provide a method to do this on-demand. - - ThunarVfsURI should have it's own parameter specification, that can be used for GValue handling. diff --git a/thunar-vfs/thunar-vfs-info.c b/thunar-vfs/thunar-vfs-info.c index ed135d377..39c425454 100644 --- a/thunar-vfs/thunar-vfs-info.c +++ b/thunar-vfs/thunar-vfs-info.c @@ -59,7 +59,6 @@ thunar_vfs_info_query (ThunarVfsInfo *info, { g_return_val_if_fail (info != NULL, FALSE); g_return_val_if_fail (info->uri == NULL, FALSE); - g_return_val_if_fail (info->target == NULL, FALSE); g_return_val_if_fail (THUNAR_VFS_IS_URI (uri), FALSE); info->uri = thunar_vfs_uri_ref (uri); @@ -95,26 +94,19 @@ thunar_vfs_info_update (ThunarVfsInfo *info, path = thunar_vfs_uri_get_path (info->uri); - if (lstat (path, &lsb) < 0) + if (G_UNLIKELY (lstat (path, &lsb) < 0)) { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), "Failed to stat file `%s': %s", path, g_strerror (errno)); return THUNAR_VFS_INFO_RESULT_ERROR; } - if (!S_ISLNK (lsb.st_mode)) + if (G_LIKELY (!S_ISLNK (lsb.st_mode))) { if (info->ctime != lsb.st_ctime || info->device != lsb.st_dev || info->inode != lsb.st_ino) { - /* no symlink, so no link target */ - if (G_UNLIKELY (info->target != NULL)) - { - g_free (info->target); - info->target = NULL; - } - info->type = (lsb.st_mode & S_IFMT) >> 12; info->mode = lsb.st_mode & 07777; info->flags = THUNAR_VFS_FILE_FLAGS_NONE; @@ -132,20 +124,6 @@ thunar_vfs_info_update (ThunarVfsInfo *info, } else { - gchar buffer[PATH_MAX + 1]; - gint length; - - /* we have a symlink, query the link target */ - length = readlink (path, buffer, sizeof (buffer) - 1); - if (length < 0) - { - g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), - "Failed to read link target of `%s': %s", path, - g_strerror (errno)); - return THUNAR_VFS_INFO_RESULT_ERROR; - } - buffer[length] = '\0'; - if (stat (path, &sb) == 0) { /* ok, link target is present */ @@ -153,11 +131,6 @@ thunar_vfs_info_update (ThunarVfsInfo *info, || info->device != sb.st_dev || info->inode != sb.st_ino) { - /* update the link target */ - g_free (info->target); - info->target = g_new (gchar, length + 1); - memcpy (info->target, buffer, length + 1); - info->type = (sb.st_mode & S_IFMT) >> 12; info->mode = sb.st_mode & 07777; info->flags = THUNAR_VFS_FILE_FLAGS_SYMLINK; @@ -181,12 +154,6 @@ thunar_vfs_info_update (ThunarVfsInfo *info, || info->device != lsb.st_dev || info->inode != lsb.st_ino) { - - /* update the link target */ - g_free (info->target); - info->target = g_new (gchar, length + 1); - memcpy (info->target, buffer, length + 1); - info->type = THUNAR_VFS_FILE_TYPE_SYMLINK; info->mode = lsb.st_mode & 07777; info->flags = THUNAR_VFS_FILE_FLAGS_SYMLINK; diff --git a/thunar-vfs/thunar-vfs-info.h b/thunar-vfs/thunar-vfs-info.h index 3ccd8085a..b62495557 100644 --- a/thunar-vfs/thunar-vfs-info.h +++ b/thunar-vfs/thunar-vfs-info.h @@ -97,9 +97,8 @@ typedef enum { /** * ThunarVfsFileFlags: * @THUNAR_VFS_FILE_FLAGS_NONE : No additional information available. - * @THUNAR_VFS_FILE_FLAGS_SYMLINK : The file is a symlink, and thereby the - * %target field is valid. Whether or not - * the other fields refer to the symlink + * @THUNAR_VFS_FILE_FLAGS_SYMLINK : The file is a symlink. Whether or not + * the info fields refer to the symlink * itself or the linked file, depends on * whether the symlink is broken or not. * @@ -178,11 +177,6 @@ typedef struct /* file's URI */ ThunarVfsURI *uri; - - /* link target in case of a symlink (as indicated by the - * %THUNAR_VFS_FILE_FLAGS_SYMLINK flag), else %NULL. - */ - char *target; } ThunarVfsInfo; #define thunar_vfs_info_init(info) \ @@ -190,16 +184,10 @@ G_STMT_START { \ (info)->type = THUNAR_VFS_FILE_TYPE_UNKNOWN; \ (info)->ctime = (ThunarVfsFileTime) -1; \ (info)->uri = NULL; \ - (info)->target = NULL; \ } G_STMT_END #define thunar_vfs_info_reset(info) \ G_STMT_START { \ - if (G_LIKELY ((info)->target != NULL)) \ - { \ - g_free ((info)->target); \ - (info)->target = NULL; \ - } \ if (G_LIKELY ((info)->uri != NULL)) \ { \ thunar_vfs_uri_unref ((info)->uri); \ -- GitLab