Next: , Previous: GnomeVFSURI, Up: Top


4 gnome-vfs-utils

various utilities functions to manipulate uris

4.1 Overview

4.2 Usage

— Function: gnome-vfs-format-uri-for-display (uri mchars) ⇒  (ret mchars)

Filter, modify, unescape and change uri to make it appropriate for display to users. The conversion is done such that the roundtrip to UTF-8 is reversible.

Rules: file: uri without fragments should appear as local paths. file: uri with fragments should appear as file:uri. All other uri appear as expected.

uri
uri to be displayed.
ret
a string which represents uri and can be displayed.

Since 2.2

— Function: gnome-vfs-url-show (url mchars) ⇒  (ret <gnome-vfs-result>)

Launches the default application or component associated with the given url.

url
url to be shown.
ret
GNOME_VFS_OK’ if the default action was launched, ‘GNOME_VFS_ERROR_BAD_PARAMETERS’ for an invalid or non-existant url, ‘GNOME_VFS_ERROR_NO_DEFAULT’ if no default action is associated with the url. Also error codes from gnome-vfs-mime-action-launch or gnome-vfs-mime-action-launch-with-env.

Since 2.4

— Function: gnome-vfs-escape-string (string mchars) ⇒  (ret mchars)

Escapes string, replacing any and all special characters with equivalent escape sequences.

string
string to be escaped.
ret
a newly allocated string equivalent to string but with all special characters escaped.
— Function: gnome-vfs-escape-path-string (path mchars) ⇒  (ret mchars)

Escapes path, replacing only special characters that would not be found in paths (so '/', '&', and '=' will not be escaped by this function).

path
string to be escaped.
ret
a newly allocated string equivalent to path but with non-path characters escaped.
— Function: gnome-vfs-escape-slashes (string mchars) ⇒  (ret mchars)

Escapes only '/' and '%' characters in string, replacing them with their escape sequence equivalents.

string
string to be escaped.
ret
a newly allocated string equivalent to string, but with no unescaped '/' or '%' characters.
— Function: gnome-vfs-escape-set (string mchars) (match_set mchars) ⇒  (ret mchars)

Escapes all characters in string which are listed in match-set.

string
string to be escaped.
match-set
a string containing all characters to be escaped in string.
ret
a newly allocated string equivalent to string but with characters in match-string escaped.
— Function: gnome-vfs-unescape-string (escaped_string mchars) (illegal_characters mchars) ⇒  (ret mchars)

Decodes escaped characters (i.e. PERCENTxx sequences) in escaped-string. Characters are encoded in PERCENTxy form, where xy is the ASCII hex code for character 16x+y.

escaped-string
an escaped uri, path, or other string.
illegal-characters
a string containing a sequence of characters considered "illegal" to be escaped, '\0' is automatically in this list.
ret
a newly allocated string with the unescaped equivalents, or ‘#f’ if escaped-string contained an escaped encoding of one of the characters in illegal-characters.
— Function: gnome-vfs-make-uri-canonical (uri mchars) ⇒  (ret mchars)

Standardizes the format of the uri, so that it can be used later in other functions that expect a canonical uri.

uri
an absolute or relative stringified uri. It might have scheme.
ret
a newly allocated string that contains the canonical representation of uri.

Since 2.2

— Function: gnome-vfs-make-path-name-canonical (path mchars) ⇒  (ret mchars)

Calls -gnome-vfs-canonicalize-pathname, allocating storage for the result and providing for a cleaner memory management.

path
a file path, relative or absolute.
ret
a canonical version of path.
— Function: gnome-vfs-make-uri-from-input (location mchars) ⇒  (ret mchars)

Takes a user input path/uri and makes a valid uri out of it.

This function is the reverse of gnome-vfs-format-uri-for-display but it also handles the fact that the user could have typed arbitrary UTF-8 in the entry showing the string.

location
a possibly mangled "uri", in UTF-8.
ret
a newly allocated uri.

Since 2.2

— Function: gnome-vfs-make-uri-from-shell-arg (uri mchars) ⇒  (ret mchars)

Similar to gnome-vfs-make-uri-from-input, except that:

1) guesses relative paths instead of http domains. 2) doesn't bother stripping leading/trailing white space. 3) doesn't bother with ~ expansion–that's done by the shell.

uri
path to make the uri from.
ret
a newly allocated string representing uri.

Since 2.2

— Function: gnome-vfs-expand-initial-tilde (path mchars) ⇒  (ret mchars)

If path starts with a ~, representing the user's home directory, expand it to the actual path location.

path
a local file path which may start with a '~'.
ret
a newly allocated string with the initial tilde (if there was one) converted to an actual path.
— Function: gnome-vfs-get-local-path-from-uri (uri mchars) ⇒  (ret mchars)

Create a local path for a file:/// uri. Do not use with uris of other methods.

uri
uri to convert to a local path.
ret
a newly allocated string containing the local path. ‘#f’ is returned on error or if the uri isn't a file: uri without a fragment identifier (or chained uri).
— Function: gnome-vfs-get-uri-from-local-path (local_full_path mchars) ⇒  (ret mchars)

Returns a file:/// URI for the local path local-full-path, such as a path provided by gtk-file-chooser-get-filename. The resulting URI may be provided, for instance, to gnome-vfs-uri-new.

On Windows local-full-path should be in the UTF-8 encoding, and can start with a drive letter, but doesn't have to.

local-full-path
a full local filesystem path (i.e. not relative).
ret
a newly allocated string containing the uri corresponding to local-full-path (‘#f’ for some bad errors).
— Function: gnome-vfs-icon-path-from-filename (filename mchars) ⇒  (ret mchars)
filename
path to a file. Could be relative or absolute path.
ret
Returns the icon path for the filename. Example: gnome_vfs_icon_path_from_filename ("nautilus/nautilus-desktop.png") will return a string forming the full path of the file nautilus-desktop.png ie $PREFIX/share/pixmaps/nautilus/nautilus-desktop.png.
— Function: gnome-vfs-is-primary-thread ⇒  (ret bool)

Check if the current thread is the thread with the main glib event loop.

ret
#t’ if the current thread is the thread with the main glib event loop.
— Function: gnome-vfs-get-uri-scheme (uri mchars) ⇒  (ret mchars)

Retrieve the scheme used in uri.

uri
a stringified uri.
ret
a newly allocated string containing the scheme, ‘#f’ if uri doesn't contain a scheme.

Since 2.2

— Function: gnome-vfs-uris-match (uri_1 mchars) (uri_2 mchars) ⇒  (ret bool)

Compare two uris.

uri-1
stringified uri to compare with uri-2.
uri-2
stringified uri to compare with uri-1.
ret
#t’ if they are the same, ‘#f’ otherwise.

Since 2.2