libgnomevfsmm  2.26.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gnome::Vfs::Uri Class Reference

#include <uri.h>

Public Member Functions

void reference () const
 
void unreference () const
 
GnomeVFSURI * gobj ()
 Provides access to the underlying C instance. More...
 
const GnomeVFSURI * gobj () const
 Provides access to the underlying C instance. More...
 
GnomeVFSURI * gobj_copy () const
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
Glib::RefPtr< Uriresolve_relative (const Glib::ustring &relative_reference)
 Create a new Uri from relative_reference to this object. More...
 
Glib::RefPtr< Uriappend_string (const Glib::ustring &uri_fragment)
 Create a new Uri object by appending uri_fragment to this Uri object. More...
 
Glib::RefPtr< Uriappend_path (const Glib::ustring &path)
 Create a new Uri object by appending path to this Uri object. More...
 
Glib::RefPtr< Uriappend_file_name (const Glib::ustring &filename)
 Create a new Uri object by appending filename to this Uri object. More...
 
Glib::ustring to_string (URIHideOptions hide_options=URI_HIDE_NONE) const
 Translate this Uri into a printable string. More...
 
Glib::RefPtr< Uridup ()
 Duplicate this Uri. More...
 
bool is_local () const
 Check if this Uri is a local (native) file system. More...
 
bool has_parent () const
 Check if this Uri has a parent or not. More...
 
Glib::RefPtr< Uriget_parent ()
 Retrieve this object's parent Uri. More...
 
Glib::RefPtr< const Uriget_parent () const
 Retrieve this object's parent Uri. More...
 
Glib::ustring get_host_name () const
 Retrieve this object's host name. More...
 
Glib::ustring get_scheme () const
 Retrieve this object's scheme. More...
 
guint get_host_port () const
 Retrieve this object's host port number. More...
 
Glib::ustring get_user_name () const
 Retrieve the user name in this object. More...
 
Glib::ustring get_password () const
 Retrieve the password for this object. More...
 
void set_host_name (const Glib::ustring &host_name)
 Set host_name as the host name accessed by this Uri. More...
 
void set_host_port (guint host_port)
 Set the host port number in this Uri. More...
 
void set_user_name (const Glib::ustring &user_name)
 Set user_name as the user name for this Uri. More...
 
void set_password (const Glib::ustring &password)
 Set password as the password for this Uri. More...
 
bool equal (const Glib::RefPtr< const Uri > &uri) const
 Compare a and b. More...
 
bool is_parent (const Glib::RefPtr< const Uri > &possible_child, bool recursive=true) const
 Check if possible_child is contained by this Uri. More...
 
Glib::ustring get_path () const
 Retrieve full path name for this Uri. More...
 
Glib::ustring get_fragment_identifier () const
 Retrieve the optional fragment identifier for this Uri. More...
 
Glib::ustring extract_dirname () const
 Extract the name of the directory in which the file pointed to by this Uri is stored as a new string. More...
 
Glib::ustring extract_short_name () const
 Retrieve base file name for this Uri, ignoring any trailing path separators. More...
 
Glib::ustring extract_short_path_name () const
 Retrieve base file name for this Uri, ignoring any trailing path separators. More...
 
Glib::RefPtr< FileInfoget_file_info (FileInfoOptions options=FILE_INFO_DEFAULT) const throw (exception)
 Retrieve the file info for this Uri. More...
 
void create_symbolic_link (const Glib::ustring &target_reference) throw (exception)
 Creates a symbolic link from this Uri to target_reference. More...
 
bool uri_exists () const
 Check if this Uri points to an existing entity. More...
 
FileSize get_volume_free_space () const throw (exception)
 This only works for URIs with the file: scheme. More...
 

Static Public Member Functions

static Glib::RefPtr< Uricreate (const Glib::ustring &uri)
 Create a new Uri from the text string uri. More...
 
static Glib::ustring make_full_from_relative (const Glib::ustring &base_uri, const Glib::ustring &relative_uri)
 Returns a full Uri given a full base URI, and a secondary URI which may be relative. More...
 
static Glib::ustring format_for_display (const Glib::ustring &uri)
 Filter, modify, unescape and change URIs to make them appropriate to display to users. More...
 
static Glib::ustring make_from_input (const Glib::ustring &uri)
 Takes a user input path/URI and makes a valid URI out of it. More...
 
static Glib::ustring make_from_input (const Glib::ustring &uri, MakeURIDirs dirs)
 
static Glib::ustring make_canonical_strip_fragment (const Glib::ustring &uri)
 If the uri passed contains a fragment (anything after a '#') strips if, then makes the URI canonical. More...
 
static bool uris_match (const Glib::ustring &uri_1, const Glib::ustring &uri_2)
 Compare two URIs. More...
 
static Glib::ustring get_scheme (const Glib::ustring &uri)
 Retrieve the scheme used in uri. More...
 
static Glib::ustring make_from_shell_arg (const Glib::ustring &uri)
 Similar to gnome_vfs_make_uri_from_input, except that: More...
 

Protected Member Functions

 Uri ()
 
void operator delete (void *, size_t)
 

Related Functions

(Note that these are not member functions.)

bool operator== (const Uri &lhs, const Uri &rhs)
 
bool operator!= (const Uri &lhs, const Uri &rhs)
 
Glib::RefPtr< Gnome::Vfs::Uriwrap (GnomeVFSURI *object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Constructor & Destructor Documentation

Gnome::Vfs::Uri::Uri ( )
protected

Member Function Documentation

Glib::RefPtr<Uri> Gnome::Vfs::Uri::append_file_name ( const Glib::ustring &  filename)

Create a new Uri object by appending filename to this Uri object.

This takes care of adding an appropriate directory separator between the end of the Uri and the start of filename if necessary.

Parameters
filenameAny "regular" file name (can include #, /, etc).
Returns
The new Uri obtained by combining this object and filename.
Glib::RefPtr<Uri> Gnome::Vfs::Uri::append_path ( const Glib::ustring &  path)

Create a new Uri object by appending path to this Uri object.

This takes care of adding an appropriate directory separator between the end of the Uri and the start of path if necessary.

Parameters
pathA non-escaped file path.
Returns
The new Uri obtained by combining this object and path.
Glib::RefPtr<Uri> Gnome::Vfs::Uri::append_string ( const Glib::ustring &  uri_fragment)

Create a new Uri object by appending uri_fragment to this Uri object.

This takes care of adding an appropriate directory separator between the end of the Uri and the start of uri_fragment if necessary.

Parameters
uri_fragmentA piece of a Uri (ie a fully escaped partial path).
Returns
The new Uri obtained by combining this object and uri_fragment.
static Glib::RefPtr<Uri> Gnome::Vfs::Uri::create ( const Glib::ustring &  uri)
static

Create a new Uri from the text string uri.

Parameters
uriA string representing a URI.
Returns
The new Uri.
void Gnome::Vfs::Uri::create_symbolic_link ( const Glib::ustring &  target_reference)
throw (exception
)

Creates a symbolic link from this Uri to target_reference.

Parameters
target_referenceURI to point the link to (full or relative path).
Glib::RefPtr<Uri> Gnome::Vfs::Uri::dup ( )

Duplicate this Uri.

Returns
A Glib::RefPtr to a new Uri that is exactly the same as this object.
bool Gnome::Vfs::Uri::equal ( const Glib::RefPtr< const Uri > &  uri) const

Compare a and b.

Parameters
bA GnomeVFSURI.
Returns
true if a and b are equal, false otherwise.

FIXME: This comparison should take into account the possiblity that unreserved characters may be escaped. ...or perhaps gnome_vfs_uri_new should unescape unreserved characters?.

Glib::ustring Gnome::Vfs::Uri::extract_dirname ( ) const

Extract the name of the directory in which the file pointed to by this Uri is stored as a new string.

The string will end with a GNOME_VFS_URI_PATH_CHR.

Returns
A string representing the parent directory.
Glib::ustring Gnome::Vfs::Uri::extract_short_name ( ) const

Retrieve base file name for this Uri, ignoring any trailing path separators.

This matches the XPG definition of basename, but not g_basename. This is often useful when you want the name of something that is pointed to by a Uri, and don't care whether the uri has a directory or file form. If this Uri points to the root of a domain, this method returns the host name; if there's no host name, returns GNOME_VFS_URI_PATH_STR.

See also: extract_short_path_name.

Returns
A string representing the unescaped short form of the name.
Glib::ustring Gnome::Vfs::Uri::extract_short_path_name ( ) const

Retrieve base file name for this Uri, ignoring any trailing path separators.

This matches the XPG definition of basename, but not g_basename. This is often useful when you want the name of something that is pointed to by a Uri, and don't care whether the uri has a directory or file form. If this Uri points to the root (including the root of any domain), this method returns GNOME_VFS_URI_PATH_STR.

See also: extract_short_name.

Returns
A string representing the escaped short form of the name.
static Glib::ustring Gnome::Vfs::Uri::format_for_display ( const Glib::ustring &  uri)
static

Filter, modify, unescape and change URIs to make them appropriate to display to users.

The conversion is done such that the roundtrip to UTF-8 is reversible.

Rules: file: URI's without fragments should appear as local paths file: URI's with fragments should appear as file: URI's All other URI's appear as expected

uri: a URI

Returns
A newly allocated UTF-8 string

.

Glib::RefPtr<FileInfo> Gnome::Vfs::Uri::get_file_info ( FileInfoOptions  options = FILE_INFO_DEFAULT) const
throw (exception
)

Retrieve the file info for this Uri.

Parameters
optionsAn enum (bitfield) representing what information to retrieve.
Returns
The information for this Uri.
Glib::ustring Gnome::Vfs::Uri::get_fragment_identifier ( ) const

Retrieve the optional fragment identifier for this Uri.

Returns
A string representing the fragment identifier for this Uri, or 0.
Glib::ustring Gnome::Vfs::Uri::get_host_name ( ) const

Retrieve this object's host name.

Returns
A string representing the host name.
guint Gnome::Vfs::Uri::get_host_port ( ) const

Retrieve this object's host port number.

Returns
The host port number used by this object. If the value is zero, the default port value for the specified toplevel access method is used.
Glib::RefPtr<Uri> Gnome::Vfs::Uri::get_parent ( )

Retrieve this object's parent Uri.

Returns
A Glib::RefPtr to this object's parent Uri.
Glib::RefPtr<const Uri> Gnome::Vfs::Uri::get_parent ( ) const

Retrieve this object's parent Uri.

Returns
A Glib::RefPtr to this object's parent Uri.
Glib::ustring Gnome::Vfs::Uri::get_password ( ) const

Retrieve the password for this object.

Returns
The password for this Uri.
Glib::ustring Gnome::Vfs::Uri::get_path ( ) const

Retrieve full path name for this Uri.

Returns
A string representing the full path of this object.
Glib::ustring Gnome::Vfs::Uri::get_scheme ( ) const

Retrieve this object's scheme.

Returns
A string representing the scheme.
static Glib::ustring Gnome::Vfs::Uri::get_scheme ( const Glib::ustring &  uri)
static

Retrieve the scheme used in uri.

Parameters
uriA stringified URI.
Returns
A string containing the scheme

.

Glib::ustring Gnome::Vfs::Uri::get_user_name ( ) const

Retrieve the user name in this object.

Returns
A string representing the user name in this Uri.
FileSize Gnome::Vfs::Uri::get_volume_free_space ( ) const
throw (exception
)

This only works for URIs with the file: scheme.

Parameters
vfs_uri
Returns
The amount of free space on a volume.
GnomeVFSURI* Gnome::Vfs::Uri::gobj ( )

Provides access to the underlying C instance.

const GnomeVFSURI* Gnome::Vfs::Uri::gobj ( ) const

Provides access to the underlying C instance.

GnomeVFSURI* Gnome::Vfs::Uri::gobj_copy ( ) const

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gnome::Vfs::Uri::has_parent ( ) const

Check if this Uri has a parent or not.

Returns
true if this Uri has a parent, false otherwise.
bool Gnome::Vfs::Uri::is_local ( ) const

Check if this Uri is a local (native) file system.

Returns
false if uri is not a local file system, true otherwise.
bool Gnome::Vfs::Uri::is_parent ( const Glib::RefPtr< const Uri > &  possible_child,
bool  recursive = true 
) const

Check if possible_child is contained by this Uri.

If recursive is false, just try the immediate parent directory, else search up through the hierarchy.

Parameters
possible_childA Glib::RefPtr to the Uri to test.
recursiveA flag to turn recursive check on.
Returns
true if possible_child is contained in this Uri.
static Glib::ustring Gnome::Vfs::Uri::make_canonical_strip_fragment ( const Glib::ustring &  uri)
static

If the uri passed contains a fragment (anything after a '#') strips if, then makes the URI canonical.

Returns
A newly allocated string containing a canonical URI.

.

static Glib::ustring Gnome::Vfs::Uri::make_from_input ( const Glib::ustring &  uri)
static

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 UTF8 in the entry showing the string.

Parameters
locationA possibly mangled "uri", in UTF8.
Returns
A newly allocated uri.

.

static Glib::ustring Gnome::Vfs::Uri::make_from_input ( const Glib::ustring &  uri,
MakeURIDirs  dirs 
)
static
static Glib::ustring Gnome::Vfs::Uri::make_from_shell_arg ( const Glib::ustring &  uri)
static

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

Parameters
locationA possibly mangled "uri".
Returns
A newly allocated uri

.

static Glib::ustring Gnome::Vfs::Uri::make_full_from_relative ( const Glib::ustring &  base_uri,
const Glib::ustring &  relative_uri 
)
static

Returns a full Uri given a full base URI, and a secondary URI which may be relative.

Parameters
base_uriA string representing the base URI.
relative_uriA URI fragment/reference to be appended to base_uri.
Returns
A string containing the URI (0 for some bad errors).
void Gnome::Vfs::Uri::operator delete ( void *  ,
size_t   
)
protected
void Gnome::Vfs::Uri::reference ( ) const
Glib::RefPtr<Uri> Gnome::Vfs::Uri::resolve_relative ( const Glib::ustring &  relative_reference)

Create a new Uri from relative_reference to this object.

Parameters
relative_referenceA string representing a possibly relative URI reference.
Returns
The new Uri.
void Gnome::Vfs::Uri::set_host_name ( const Glib::ustring &  host_name)

Set host_name as the host name accessed by this Uri.

Parameters
host_nameA string representing a host name.
void Gnome::Vfs::Uri::set_host_port ( guint  host_port)

Set the host port number in this Uri.

If host_port is zero, the default port for this object's toplevel access method is used.

Parameters
host_portA TCP/IP port number.
void Gnome::Vfs::Uri::set_password ( const Glib::ustring &  password)

Set password as the password for this Uri.

Parameters
passwordA password string.
void Gnome::Vfs::Uri::set_user_name ( const Glib::ustring &  user_name)

Set user_name as the user name for this Uri.

Parameters
user_nameA string representing a user name on the host accessed by this object.
Glib::ustring Gnome::Vfs::Uri::to_string ( URIHideOptions  hide_options = URI_HIDE_NONE) const

Translate this Uri into a printable string.

The string will not contain the Uri elements specified by hide_options.

Parameters
hide_optionsBitmask specifying what URI elements (e.g. password, user name etc.) should NOT be represented in the returned string.
Returns
A Glib::ustring representing this Uri.
void Gnome::Vfs::Uri::unreference ( ) const
bool Gnome::Vfs::Uri::uri_exists ( ) const

Check if this Uri points to an existing entity.

Returns
true if this Uri exists.
static bool Gnome::Vfs::Uri::uris_match ( const Glib::ustring &  uri_1,
const Glib::ustring &  uri_2 
)
static

Compare two URIs.

Parameters
uri_1Stringified URI to compare with uri_2.
uri_2Stringified URI to compare with uri_1.
Returns
true if they are the same, false otherwise.

.

Friends And Related Function Documentation

bool operator!= ( const Uri lhs,
const Uri rhs 
)
related
Parameters
lhsThe left-hand side
rhsThe right-hand side
Returns
The result
bool operator== ( const Uri lhs,
const Uri rhs 
)
related
Parameters
lhsThe left-hand side
rhsThe right-hand side
Returns
The result
Glib::RefPtr< Gnome::Vfs::Uri > wrap ( GnomeVFSURI *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file: