mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-11-05 16:04:31 +00:00
directory: Restructure and document is_local_or_fuse()
Avoid calling g_file_get_path() if we have enough information. Clarify the purpose of this function.
This commit is contained in:
parent
e327f8f445
commit
b92a7d5232
1 changed files with 31 additions and 9 deletions
|
@ -761,6 +761,19 @@ nautilus_directory_new (GFile *location)
|
|||
return handling_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_directory_is_local_or_fuse:
|
||||
*
|
||||
* @directory: a #NautilusDirectory
|
||||
*
|
||||
* Checks whether this directory contains files with local paths. Usually, this
|
||||
* means the local path can be obtained by calling g_file_get_path(). As an
|
||||
* exception, the local URI for files in recent:// can only be obtained from the
|
||||
* G_FILE_ATTRIBUTE_STANDARD_TARGET_URI attribute.
|
||||
*
|
||||
* Returns: %TRUE if a local path is known to be obtainable for all files in
|
||||
* this directory. Otherwise, %FALSE.
|
||||
*/
|
||||
gboolean
|
||||
nautilus_directory_is_local (NautilusDirectory *directory)
|
||||
{
|
||||
|
@ -777,19 +790,28 @@ nautilus_directory_is_local (NautilusDirectory *directory)
|
|||
gboolean
|
||||
nautilus_directory_is_local_or_fuse (NautilusDirectory *directory)
|
||||
{
|
||||
g_autofree char *path = NULL;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
|
||||
g_return_val_if_fail (directory->details->location, FALSE);
|
||||
|
||||
/* If the glib reports a path, then it can use FUSE to convert the uri
|
||||
* to a local path
|
||||
*/
|
||||
path = g_file_get_path (directory->details->location);
|
||||
|
||||
return nautilus_directory_is_in_recent (directory) ||
|
||||
g_file_is_native (directory->details->location) ||
|
||||
path != NULL;
|
||||
if (nautilus_directory_is_in_recent (directory)
|
||||
|| g_file_is_native (directory->details->location))
|
||||
{
|
||||
/* Native files have a local path by definition. The files in recent:/
|
||||
* have a local URI stored in the standard::target-uri attribute. */
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_autofree char *path = NULL;
|
||||
|
||||
/* Non-native files may have local paths in FUSE mounts. The only way to
|
||||
* know if that's the case is to test if GIO reports a path.
|
||||
*/
|
||||
path = g_file_get_path (directory->details->location);
|
||||
|
||||
return (path != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
Loading…
Reference in a new issue