Re: gnome-vfs freeze break request - executable files



Le mardi 07 septembre 2004 à 15:49 +0200, Alexander Larsson a écrit :
> Currently, all executable files in nautilus are launched when you open
> them. This is quite bad, because normal files are sometimes executable.
> Some filesystems such as FAT even show all files as executable.
> 
> This is a regression introduced by the new mimesystem. The new code
> doesn't implement the can_be_executable check, nor mime_type_is_known,
> which are both needed for nautilus to work correctly here.
> 
> This patch fixes this. Ok to commit?
> 
> Index: libgnomevfs/gnome-vfs-mime-info.c
> ===================================================================
> RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime-info.c,v
> retrieving revision 1.79
> diff -u -p -r1.79 gnome-vfs-mime-info.c
> --- libgnomevfs/gnome-vfs-mime-info.c	26 Jul 2004 19:31:36 -0000	1.79
> +++ libgnomevfs/gnome-vfs-mime-info.c	7 Sep 2004 13:43:49 -0000
> @@ -561,6 +561,10 @@ gnome_vfs_mime_get_value (const char *mi
>  		return entry->parent_classes;
>  	} else if (!strcmp (key, "aliases")) {
>  		return entry->aliases;
> +	} else if (!strcmp (key, "can_be_executable")) {
> +		if (gnome_vfs_mime_type_get_equivalence (mime_type, "application/x-executable") != GNOME_VFS_MIME_UNRELATED ||
> +		    gnome_vfs_mime_type_get_equivalence (mime_type, "text/plain") != GNOME_VFS_MIME_UNRELATED)
> +			return "TRUE";
>  	}
>  
>  	return NULL;
> @@ -577,6 +581,8 @@ gnome_vfs_mime_get_value (const char *mi
>  gboolean
>  gnome_vfs_mime_type_is_known (const char *mime_type)
>  {
> +	MimeEntry *entry;
> +	
>  	if (mime_type == NULL) {
>  		return FALSE;
>  	}
> @@ -589,7 +595,12 @@ gnome_vfs_mime_type_is_known (const char
>  
>  	reload_if_needed ();
>  
> -	return FALSE;
> +	entry = get_entry (mime_type);
> +	
> +	/* TODO: Should look for aliases too, which needs
> +	   a alias -> mimetype mapping */
> +
> +	return entry != NULL;
>  }
>  
>  /**

Hmm, aren't you leaking the entry ?

-- 
Frederic Crozat <fcrozat mandrakesoft com>
Mandrakesoft




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