Skip to content
Snippets Groups Projects
Commit c2ee9b2c authored by Benedikt Meurer's avatar Benedikt Meurer
Browse files

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)
parent e5aa4256
No related branches found
No related tags found
No related merge requests found
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
......
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.
......
......@@ -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;
......
......@@ -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); \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment