/* nautilus_directory_get_name_for_self_as_new_file: * * Get a name to display for the file representing this * directory. This is called only when there's no VFS * directory for this NautilusDirectory. */ char * nautilus_directory_get_name_for_self_as_new_file (NautilusDirectory *directory) { GFile *file; char *directory_uri; char *scheme; char *name; char *hostname = NULL; directory_uri = nautilus_directory_get_uri (directory); file = g_file_new_for_uri (directory_uri); scheme = g_file_get_uri_scheme (file); g_object_unref (file); nautilus_uri_parse (directory_uri, &hostname, NULL, NULL); if (hostname == NULL || (strlen (hostname) == 0)) { name = g_strdup (directory_uri); } else if (scheme == NULL) { name = g_strdup (hostname); } else { /* Translators: this is of the format "hostname (uri-scheme)" */ name = g_strdup_printf (_("%s (%s)"), hostname, scheme); } g_free (directory_uri); g_free (scheme); g_free (hostname); return name; }
/* Returns a reffed NautilusFile object for this directory. */ NautilusFile * nautilus_directory_get_corresponding_file (NautilusDirectory *directory) { NautilusFile *file; char *uri; file = nautilus_directory_get_existing_corresponding_file (directory); if (file == NULL) { uri = nautilus_directory_get_uri (directory); file = nautilus_file_get_by_uri (uri); g_free (uri); } return file; }
/* Returns a reffed NautilusFile object for this directory, but only if the * NautilusFile object has already been created. */ NautilusFile * nautilus_directory_get_existing_corresponding_file (NautilusDirectory *directory) { NautilusFile *file; char *uri; file = directory->details->as_file; if (file != NULL) { nautilus_file_ref (file); return file; } uri = nautilus_directory_get_uri (directory); file = nautilus_file_get_existing_by_uri (uri); g_free (uri); return file; }
static char * real_get_name_for_self_as_new_file (NautilusDirectory *directory) { char *directory_uri; char *name, *colon; directory_uri = nautilus_directory_get_uri (directory); colon = strchr (directory_uri, ':'); if (colon == NULL || colon == directory_uri) { name = g_strdup (directory_uri); } else { name = g_strndup (directory_uri, colon - directory_uri); } g_free (directory_uri); return name; }