Index: thunar/thunar-file.c =================================================================== --- thunar/thunar-file.c (revision 21175) +++ thunar/thunar-file.c (working copy) @@ -500,22 +500,37 @@ { /* we're the owner, so the usr permissions must be granted */ result = ((mode & usr_permissions) == 0); + + /* release the user */ + g_object_unref (G_OBJECT (user)); } else { group = thunar_file_get_group (file); if (G_LIKELY (group != NULL)) { - /* check the group permissions */ - groups = thunar_vfs_user_get_groups (user); - for (lp = groups; lp != NULL; lp = lp->next) - if (THUNAR_VFS_GROUP (lp->data) == group) - { - g_object_unref (G_OBJECT (user)); - g_object_unref (G_OBJECT (group)); - return ((mode & grp_permissions) == 0); - } + /* release the file owner */ + g_object_unref (G_OBJECT (user)); + /* determine the effective user */ + user = thunar_vfs_user_manager_get_user_by_id (user_manager, effective_user_id); + if (G_LIKELY (user != NULL)) + { + /* check the group permissions */ + groups = thunar_vfs_user_get_groups (user); + for (lp = groups; lp != NULL; lp = lp->next) + if (THUNAR_VFS_GROUP (lp->data) == group) + { + g_object_unref (G_OBJECT (user)); + g_object_unref (G_OBJECT (group)); + return ((mode & grp_permissions) == 0); + } + + /* release the effective user */ + g_object_unref (G_OBJECT (user)); + } + + /* release the file group */ g_object_unref (G_OBJECT (group)); } @@ -523,8 +538,6 @@ result = ((mode & oth_permissions) == 0); } - g_object_unref (G_OBJECT (user)); - return result; } @@ -1330,46 +1343,6 @@ /** - * thunar_file_is_executable: - * @file : a #ThunarFile instance. - * - * Determines whether the owner of the current process is allowed - * to execute the @file (or enter the directory refered to by - * @file). - * - * Return value: %TRUE if @file can be executed. - **/ -gboolean -thunar_file_is_executable (const ThunarFile *file) -{ - g_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); - return ((file->info->flags & THUNAR_VFS_FILE_FLAGS_EXECUTABLE) != 0); -} - - - -/** - * thunar_file_is_readable: - * @file : a #ThunarFile instance. - * - * Determines whether the owner of the current process is allowed - * to read the @file. - * - * Return value: %TRUE if @file can be read. - **/ -gboolean -thunar_file_is_readable (const ThunarFile *file) -{ - g_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); - return !thunar_file_denies_access_permission (file, - THUNAR_VFS_FILE_MODE_USR_READ, - THUNAR_VFS_FILE_MODE_GRP_READ, - THUNAR_VFS_FILE_MODE_OTH_READ); -} - - - -/** * thunar_file_is_renameable: * @file : a #ThunarFile instance. * @@ -1405,29 +1378,6 @@ /** - * thunar_file_is_writable: - * @file : a #ThunarFile instance. - * - * Determines whether the owner of the current process is allowed - * to write the @file. - * - * Return value: %TRUE if @file can be read. - **/ -gboolean -thunar_file_is_writable (const ThunarFile *file) -{ - g_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); - return !thunar_file_denies_access_permission (file, - THUNAR_VFS_FILE_MODE_USR_WRITE, - THUNAR_VFS_FILE_MODE_GRP_WRITE, - THUNAR_VFS_FILE_MODE_OTH_WRITE); - - -} - - - -/** * thunar_file_get_actions: * @file : a #ThunarFile instance. * @window : a #GdkWindow instance. Index: thunar/thunar-file.h =================================================================== --- thunar/thunar-file.h (revision 21175) +++ thunar/thunar-file.h (working copy) @@ -155,10 +155,7 @@ ThunarVfsUser *thunar_file_get_user (const ThunarFile *file); gboolean thunar_file_is_chmodable (const ThunarFile *file); -gboolean thunar_file_is_executable (const ThunarFile *file); -gboolean thunar_file_is_readable (const ThunarFile *file); gboolean thunar_file_is_renameable (const ThunarFile *file); -gboolean thunar_file_is_writable (const ThunarFile *file); GList *thunar_file_get_actions (ThunarFile *file, GtkWidget *window); @@ -359,6 +356,40 @@ #define thunar_file_is_directory(file) (THUNAR_FILE ((file))->info->type == THUNAR_VFS_FILE_TYPE_DIRECTORY) /** + * thunar_file_is_executable: + * @file : a #ThunarFile instance. + * + * Determines whether the owner of the current process is allowed + * to execute the @file (or enter the directory refered to by + * @file). + * + * Return value: %TRUE if @file can be executed. + **/ +#define thunar_file_is_executable(file) (THUNAR_FILE ((file))->info->flags & THUNAR_VFS_FILE_FLAGS_EXECUTABLE) + +/** + * thunar_file_is_readable: + * @file : a #ThunarFile instance. + * + * Determines whether the owner of the current process is allowed + * to read the @file. + * + * Return value: %TRUE if @file can be read. + **/ +#define thunar_file_is_readable(file) (THUNAR_FILE ((file))->info->flags & THUNAR_VFS_FILE_FLAGS_READABLE) + +/** + * thunar_file_is_writable: + * @file : a #ThunarFile instance. + * + * Determines whether the owner of the current process is allowed + * to write the @file. + * + * Return value: %TRUE if @file can be read. + **/ +#define thunar_file_is_writable(file) (THUNAR_FILE ((file))->info->flags & THUNAR_VFS_FILE_FLAGS_WRITABLE) + +/** * thunar_file_is_hidden: * @file : a #ThunarFile instance. * Index: thunar-vfs/thunar-vfs-types.h =================================================================== --- thunar-vfs/thunar-vfs-types.h (revision 21175) +++ thunar-vfs/thunar-vfs-types.h (working copy) @@ -129,6 +129,10 @@ * hidden files. Hidden files start with a * dot character ('.') or end with a tilde * character ('~'). + * @THUNAR_VFS_FILE_FLAGS_READABLE : The file can most probably be read by the + * current user. + * @THUNAR_VFS_FILE_FLAGS_WRITABLE : The file can most probably be written by + * the current user. * * Flags providing additional information about the * file system entity. @@ -139,6 +143,8 @@ THUNAR_VFS_FILE_FLAGS_SYMLINK = 1L << 0, THUNAR_VFS_FILE_FLAGS_EXECUTABLE = 1L << 1, THUNAR_VFS_FILE_FLAGS_HIDDEN = 1L << 2, + THUNAR_VFS_FILE_FLAGS_READABLE = 1L << 3, + THUNAR_VFS_FILE_FLAGS_WRITABLE = 1L << 4, } ThunarVfsFileFlags; typedef dev_t ThunarVfsFileDevice; Index: thunar-vfs/thunar-vfs-info.c =================================================================== --- thunar-vfs/thunar-vfs-info.c (revision 21175) +++ thunar-vfs/thunar-vfs-info.c (working copy) @@ -843,6 +843,14 @@ } } + /* check if we can read the file */ + if ((info->mode & 00444) != 0 && g_access (absolute_path, R_OK) == 0) + info->flags |= THUNAR_VFS_FILE_FLAGS_READABLE; + + /* check if we can write to the file */ + if ((info->mode & 00222) != 0 && g_access (absolute_path, W_OK) == 0) + info->flags |= THUNAR_VFS_FILE_FLAGS_WRITABLE; + /* determine the file's mime type */ switch (info->type) {