logo top
Main Page   Widgets   glibmm Namespaces   Book  

Gio::File Class Reference

File and directory handling. More...

Inheritance diagram for Gio::File:

Inheritance graph
[legend]
List of all members.

Public Types

typedef sigc::slot< void,
goffset, goffset > 
SlotFileProgress
 A signal handler would be, for instance: void on_file_progress(goffset current_num_bytes, goffset total_num_bytes);.
typedef sigc::slot< bool,
const char*, goffset > 
SlotReadMore
 A signal handler would be, for instance: bool on_read_more(const char* file_contents, goffset file_size);.

Public Member Functions

virtual ~File ()
GFile* gobj ()
 Provides access to the underlying C GObject.
const GFile* gobj () const
 Provides access to the underlying C GObject.
Glib::RefPtr<Filedup () const
 Duplicates a G::File handle.
guint hash () const
 Creates a hash value for a G::File.
virtual bool equal (const Glib::RefPtr<File>& other) const
std::string get_basename () const
 Gets the basename (the last component of the path) for a given G::File.
std::string get_path () const
 Gets the local pathname for G::File, if one exists.
std::string get_uri () const
 Gets the URI for the file .
Glib::ustring get_parse_name () const
 Gets the parse name of the file .
Glib::RefPtr<Fileget_parent () const
 Gets the parent directory for the file .
Glib::RefPtr<Fileget_child (const std::string& name) const
 Gets a specific child of file with name equal to name .
Glib::RefPtr<Fileget_child_for_display_name (const std::string& display_name) const
 Gets the child of file for a given display_name (i.e. a UTF8 version of the name).
bool contains_file (const Glib::RefPtr<File>& descendant) const
 Checks whether parent (recursively) contains the specified descendent .
std::string get_relative_path (const Glib::RefPtr<File>& descendant) const
 Gets the path for descendant relative to parent .
Glib::RefPtr<Fileresolve_relative_path (const std::string& relative_path) const
 Resolves a relative path for file to an absolute path.
bool is_native () const
 Checks to see if a file is native to the platform.
bool has_uri_scheme (const std::string& uri_scheme) const
 Checks to see if a G::File has a given URI scheme.
std::string get_uri_scheme () const
 Gets the URI scheme for a G::File.
Glib::RefPtr<FileInputStreamread (const Glib::RefPtr<Cancellable>& cancellable)
 Opens a file for reading.
Glib::RefPtr<const FileInputStreamread (const Glib::RefPtr<Cancellable>& cancellable) const
 Opens a file for reading.
void read_async (int io_priority, Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
Glib::RefPtr<FileInputStreamread_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes an asynchronous file read operation started with g_file_read_async().
Glib::RefPtr<FileOutputStreamappend_to (FileCreateFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Gets an output stream for appending data to the file.
Glib::RefPtr<FileOutputStreamcreate_file (FileCreateFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Creates a new file and returns an output stream for writing to it.
Glib::RefPtr<FileOutputStreamreplace (const std::string& etag, bool make_backup, FileCreateFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Returns: a G::FileOutputStream or 0 on error.
void append_to_async (FileCreateFlags flags, int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
 Asynchronously opens the file for appending.
void append_to_async (FileCreateFlags flags, int io_priority, const SlotAsyncReady& slot)
 Asynchronously opens the file for appending.
Glib::RefPtr<FileOutputStreamappend_to_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes an asynchronous file append operation started with g_file_append_to_async().
void create_file_async (FileCreateFlags flags, int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
 Asynchronously creates a new file and returns an output stream for writing to it.
void create_file_async (FileCreateFlags flags, int io_priority, const SlotAsyncReady& slot)
 Asynchronously creates a new file and returns an output stream for writing to it.
Glib::RefPtr<FileOutputStreamcreate_file_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes an asynchronous file create operation started with g_file_create_async().
void replace_async (const std::string& etag, bool make_backup, FileCreateFlags flags, int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
 Asyncronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.
void replace_async (const std::string& etag, bool make_backup, FileCreateFlags flags, int io_priority, const SlotAsyncReady& slot)
 Asyncronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.
Glib::RefPtr<FileOutputStreamreplace_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes an asynchronous file replace operation started with g_file_replace_async().
Glib::RefPtr<FileInfoquery_info (const std::string& attributes, FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Gets the requested information about specified file .
void query_info_async (const std::string& attributes, FileQueryInfoFlags flags, int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
 Asynchronously gets the requested information about specified file.
void query_info_async (const std::string& attributes, FileQueryInfoFlags flags, int io_priority, const SlotAsyncReady& slot)
 Asynchronously gets the requested information about specified file.
Glib::RefPtr<FileInfoquery_info_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes an asynchronous file info query.
Glib::RefPtr<FileInfoquery_filesystem_info (const std::string& attributes, const Glib::RefPtr<Cancellable>& cancellable)
 Similar to g_file_query_info(), but obtains information about the filesystem the file is on, rather than the file itself.
Glib::RefPtr<FileEnumeratorenumerate_children (const std::string& attributes, FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Gets the requested information about the files in a directory.
void enumerate_children_async (const std::string& attributes, FileQueryInfoFlags flags, int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
 Asynchronously gets the requested information about the files in a directory.
void enumerate_children_async (const std::string& attributes, FileQueryInfoFlags flags, int io_priority, const SlotAsyncReady& slot)
 Asynchronously gets the requested information about the files in a directory.
Glib::RefPtr<FileEnumeratorenumerate_children_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes an async enumerate children operation.
Glib::RefPtr<Fileset_display_name (const std::string& display_name, const Glib::RefPtr<Cancellable>& cancellable)
 Renames file to the specified display name.
void set_display_name_async (const std::string& display_name, int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
 Asynchronously sets the display name for a given Gio::File.
void set_display_name_async (const std::string& display_name, int io_priority, const SlotAsyncReady& slot)
 Asynchronously sets the display name for a given Gio::File.
Glib::RefPtr<Fileset_display_name_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes setting a display name started with g_file_set_display_name_async().
bool remove (const Glib::RefPtr<Cancellable>& cancellable)
 Deletes a file.
bool trash (const Glib::RefPtr<Cancellable>& cancellable)
 Sends file to the "Trashcan", if possible.
bool copy (const Glib::RefPtr<File>& destination, FileCopyFlags flags, const Glib::RefPtr<Cancellable>& cancellable, const SlotFileProgress& slot)
bool copy (const Glib::RefPtr<File>& destination, FileCopyFlags flags, const SlotFileProgress& slot)
bool move (const Glib::RefPtr<File>& destination, FileCopyFlags flags, const Glib::RefPtr<Cancellable>& cancellable, const SlotFileProgress& slot)
bool move (const Glib::RefPtr<File>& destination, FileCopyFlags flags, const SlotFileProgress& slot)
bool make_directory (const Glib::RefPtr<Cancellable>& cancellable)
 Creates a directory.
bool make_symbolic_link (const std::string& symlink_value, const Glib::RefPtr<Cancellable>& cancellable)
 Creates a symbolic link.
Glib::RefPtr<FileAttributeInfoListquery_settable_attributes (const Glib::RefPtr<Cancellable>& cancellable)
 Obtain the list of settable attributes for the file.
Glib::RefPtr<FileAttributeInfoListquery_writable_namespaces (const Glib::RefPtr<Cancellable>& cancellable)
 Obtain the list of attribute namespaces where new attributes can be created by a user.
bool set_attributes_from_info (const Glib::RefPtr<FileInfo>& info, FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Tries to set all attributes in the G::FileInfo on the target values, not stopping on the first error.
void set_attributes_async (const Glib::RefPtr<FileInfo>& info, FileQueryInfoFlags flags, int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
 Asynchronously sets the attributes of file with info.
void set_attributes_async (const Glib::RefPtr<FileInfo>& info, FileQueryInfoFlags flags, int io_priority, const SlotAsyncReady& slot)
 Asynchronously sets the attributes of file with info.
bool set_attributes_finish (const Glib::RefPtr<AsyncResult>& result, const Glib::RefPtr<FileInfo>& info)
bool set_attribute_string (const std::string& attribute, const std::string& value, FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Sets attribute of type G::FILE_ATTRIBUTE_TYPE_STRING to value .
bool set_attribute_byte_string (const std::string& attribute, const std::string& value, FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Sets attribute of type G::FILE_ATTRIBUTE_TYPE_BYTE_STRING to value .
bool set_attribute_uint32 (const std::string& attribute, guint32 value, FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Sets attribute of type G::FILE_ATTRIBUTE_TYPE_UINT32 to value .
bool set_attribute_int32 (const std::string& attribute, gint32 value, FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Sets attribute of type G::FILE_ATTRIBUTE_TYPE_INT32 to value .
bool set_attribute_uint64 (const std::string& attribute, guint64 value, FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Sets attribute of type G::FILE_ATTRIBUTE_TYPE_UINT64 to value .
bool set_attribute_int64 (const std::string& attribute, gint64 value, FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Sets attribute of type G::FILE_ATTRIBUTE_TYPE_INT64 to value .
void mount_mountable (const Glib::RefPtr<MountOperation>& mount_operation, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
 Mounts a file of type FILE_TYPE_MOUNTABLE.
void mount_mountable (const Glib::RefPtr<MountOperation>& mount_operation, const SlotAsyncReady& slot)
 Mounts a file of type FILE_TYPE_MOUNTABLE.
void mount_mountable (const SlotAsyncReady& slot)
 Mounts a file of type FILE_TYPE_MOUNTABLE without user interaction.
Glib::RefPtr<Filemount_mountable_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes a mount operation.
void unmount_mountable (GMountUnmountFlags flags, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
 Unmounts a file of type FILE_TYPE_MOUNTABLE.
void unmount_mountable (GMountUnmountFlags flags, const SlotAsyncReady& slot)
 Unmounts a file of type FILE_TYPE_MOUNTABLE.
bool unmount_mountable_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes an unmount operation, see g_file_unmount_mountable() for details.
void eject_mountable (GMountUnmountFlags flags, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
 Starts an asynchronous eject on a mountable.
void eject_mountable (GMountUnmountFlags flags, const SlotAsyncReady& slot)
 Starts an asynchronous eject on a mountable.
bool eject_mountable_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes an asynchronous eject operation started by g_file_eject_mountable().
bool load_contents (const Glib::RefPtr<Cancellable>& cancellable, char** contents, gsize& length, char** etag_out)
 Loads the content of the file into memory, returning the size of the data.
void load_contents_async (const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
void load_contents_async (const SlotAsyncReady& slot)
bool load_contents_finish (const Glib::RefPtr<AsyncResult>& result, char** contents, gsize& length, char** etag_out)
 Finishes an asynchronous load of the file 's contents.
void load_partial_contents_async (const Glib::RefPtr<Cancellable>& cancellable, const SlotReadMore& slot_read_more, const SlotAsyncReady& slot_async_ready)
 Reads the partial contents of a file.
void load_partial_contents_async (const SlotReadMore& slot_read_more, const SlotAsyncReady& slot_async_ready)
 Reads the partial contents of a file.
bool load_partial_contents_finish (const Glib::RefPtr<AsyncResult>& result, char** contents, gsize& length, char** etag_out)
 Finishes an asynchronous partial load operation that was started with g_file_load_partial_contents_async().
void replace_contents (const char* contents, gsize length, const char* etag, bool make_backup, FileCreateFlags flags, char** new_etag, const Glib::RefPtr<Cancellable>& cancellable)
 Replaces the contents of file with contents of length bytes.
void replace_contents_async (const char* contents, gsize length, const char* etag, bool make_backup, FileCreateFlags flags, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
void replace_contents_async (const char* contents, gsize length, const char* etag, bool make_backup, FileCreateFlags flags, const SlotAsyncReady& slot)
void replace_contents_finish (const Glib::RefPtr<AsyncResult>& result, char** new_etag)
 Finishes an asynchronous replace of the given file .
virtual Glib::RefPtr<Filedup_vfunc ()
virtual guint hash_vfunc () const
virtual std::string get_basename_vfunc () const
virtual std::string get_path_vfunc () const
virtual std::string get_uri_vfunc () const
virtual std::string get_parse_name_vfunc () const
virtual Glib::RefPtr<Fileget_parent_vfunc () const
virtual bool contains_file_vfunc (const Glib::RefPtr<File>& descendant) const
virtual std::string get_relative_path_vfunc (const Glib::RefPtr<File>& descendant) const
virtual Glib::RefPtr<Fileresolve_relative_path_vfunc (const std::string& relative_path) const
virtual bool is_native_vfunc () const
virtual bool has_uri_scheme_vfunc (const std::string& uri_scheme) const

Static Public Member Functions

static void add_interface (GType gtype_implementer)
static Glib::RefPtr<Filecreate_for_path (const std::string& path)
 Constructs a File for a given path.
static Glib::RefPtr<Filecreate_for_uri (const std::string& uri)
 Constructs a File for a given URI.
static Glib::RefPtr<Filecreate_for_commandline_arg (const std::string& arg)
 Constructs a File for a given argument from the command line.
static Glib::RefPtr<Filecreate_for_parse_name (const Glib::ustring& parse_name)

Related Functions

(Note that these are not member functions.)

bool operator== (const Glib::RefPtr<File>& lhs, const Glib::RefPtr<File>& rhs)
bool operator!= (const Glib::RefPtr<File>& lhs, const Glib::RefPtr<File>& rhs)
Glib::RefPtr<Gio::Filewrap (GFile* object, bool take_copy=false)
 A Glib::wrap() method for this object.

Detailed Description

File and directory handling.

Gio::File is a high level abstraction for manipulating files on a virtual file system. Gio::Files are lightweight, immutable objects that do no I/O upon creation. It is necessary to understand that a Gio::File object does not represent a file, merely a handle to a file. All file I/O is implemented as streaming operations (see Gio::InputStream and Gio::OutputStream).

A GioFile can be constructed from a path, URI, or a command line argument.

You can move through the filesystem with Gio::File handles with get_parent() to get a handle to the parent directory, get_child() to get a handle to a child within a directory, and resolve_relative_path() to resolve a relative path between two Gio::Files.

Many Gio::File operations have both synchronous and asynchronous versions to suit your application. Asynchronous versions of synchronous functions simply have _async() appended to their function names. The asynchronous I/O functions call a SlotAsyncReady callback slot which is then used to finalize the operation, producing a AsyncResult which is then passed to the function's matching _finish() operation.

Some Gio::File operations do not have synchronous analogs, as they may take a very long time to finish, and blocking may leave an application unusable. Notable cases include: mount_mountable() to mount a mountable file, unmount_mountable() to unmount a mountable file, and eject_mountable() to eject a mountable file.

One notable feature of Gio::Files are entity tags, or "etags" for short. Entity tags are somewhat like a more abstract version of the traditional mtime, and can be used to quickly determine if the file has been modified from the version on the file system. See the HTTP 1.1 specification for HTTP Etag headers, which are a very similar concept.

Since glibmm 2.16:


Member Typedef Documentation

typedef sigc::slot<void, goffset, goffset> Gio::File::SlotFileProgress

A signal handler would be, for instance: void on_file_progress(goffset current_num_bytes, goffset total_num_bytes);.

typedef sigc::slot<bool, const char*, goffset> Gio::File::SlotReadMore

A signal handler would be, for instance: bool on_read_more(const char* file_contents, goffset file_size);.


Constructor & Destructor Documentation

virtual Gio::File::~File (  )  [virtual]


Member Function Documentation

static void Gio::File::add_interface ( GType  gtype_implementer  )  [static]

GFile* Gio::File::gobj (  )  [inline]

Provides access to the underlying C GObject.

Reimplemented from Glib::Interface.

const GFile* Gio::File::gobj (  )  const [inline]

Provides access to the underlying C GObject.

Reimplemented from Glib::Interface.

static Glib::RefPtr<File> Gio::File::create_for_path ( const std::string path  )  [static]

Constructs a File for a given path.

This operation never fails, but the returned object might not support any I/O operation if path is malformed.

Parameters:
path A string containing a relative or absolute path.
Returns:
A new instantiation of an appropriate Gio::File class.

static Glib::RefPtr<File> Gio::File::create_for_uri ( const std::string uri  )  [static]

Constructs a File for a given URI.

This operation never fails, but the returned object might not support any I/O operation if path is malformed.

Parameters:
uri A string containing a URI.
Returns:
A new instantiation of an appropriate Gio::File class.

static Glib::RefPtr<File> Gio::File::create_for_commandline_arg ( const std::string arg  )  [static]

Constructs a File for a given argument from the command line.

The value of arg can be either a URI, an absolute path or a relative path resolved relative to the current working directory. This operation never fails, but the returned object might not support any I/O operation if arg points to a malformed path.

Parameters:
arg A string containing a relative or absolute path.
Returns:
A new instantiation of an appropriate Gio::File class.

static Glib::RefPtr<File> Gio::File::create_for_parse_name ( const Glib::ustring parse_name  )  [static]

Glib::RefPtr<File> Gio::File::dup (  )  const

Duplicates a G::File handle.

This operation does not duplicate the actual file or directory represented by the G::File; see g_file_copy() if attempting to copy a file.

This call does no blocking i/o.

Returns:
G::File that is a duplicate of the given G::File.

guint Gio::File::hash (  )  const

Creates a hash value for a G::File.

This call does no blocking i/o.

Parameters:
file gconstpointer to a G::File.
Returns:
0 if file is not a valid G::File, otherwise an integer that can be used as hash value for the G::File. This function is intended for easily hashing a G::File to add to a G::HashTable or similar data structure.

virtual bool Gio::File::equal ( const Glib::RefPtr<File>&  other  )  const [virtual]

std::string Gio::File::get_basename (  )  const

Gets the basename (the last component of the path) for a given G::File.

If called for the toplevel of a system (such as the filesystem root or a uri like sftp://host/ it will return a single directory separator (and on Windows, possibly a drive letter).

This call does no blocking i/o.

Returns:
String containing the G::File's base name, or 0 if given G::File is invalid. The returned string should be freed with Glib::free() when no longer needed.

std::string Gio::File::get_path (  )  const

Gets the local pathname for G::File, if one exists.

This call does no blocking i/o.

Returns:
String containing the G::File's path, or 0 if no such path exists. The returned string should be freed with Glib::free() when no longer needed.

std::string Gio::File::get_uri (  )  const

Gets the URI for the file .

This call does no blocking i/o.

Returns:
A string containing the G::File's URI. The returned string should be freed with Glib::free() when no longer needed.

Glib::ustring Gio::File::get_parse_name (  )  const

Gets the parse name of the file .

A parse name is a UTF-8 string that describes the file such that one can get the G::File back using g_file_parse_name().

This is generally used to show the G::File as a nice string in a user interface, like in a location entry.

For local files with names that can safely be converted to UTF8 the pathname is used, otherwise the IRI is used (a form of URI that allows UTF8 characters unescaped).

This call does no blocking i/o.

Returns:
A string containing the G::File's parse name. The returned string should be freed with Glib::free() when no longer needed.

Glib::RefPtr<File> Gio::File::get_parent (  )  const

Gets the parent directory for the file .

If the file represents the root directory of the file system, then 0 will be returned.

This call does no blocking i/o.

Returns:
A G::File structure to the parent of the given G::File or 0 if there is no parent.

Glib::RefPtr<File> Gio::File::get_child ( const std::string name  )  const

Gets a specific child of file with name equal to name .

Note that the file with that specific name might not exist, but you can still have a G::File that points to it. You can use this for instance to create that file.

This call does no blocking i/o.

Parameters:
name String containing the child's name.
Returns:
A G::File to a child specified by name .

Glib::RefPtr<File> Gio::File::get_child_for_display_name ( const std::string display_name  )  const

Gets the child of file for a given display_name (i.e. a UTF8 version of the name).

If this function fails, it returns 0 and error will be set. This is very useful when constructing a GFile for a new file and the user entered the filename in the user interface, for instance when you select a directory and type a filename in the file selector.

This call does no blocking i/o.

Parameters:
display_name String to a possible child.
error G::Error.
Returns:
A G::File to the specified child, or 0 if the display name couldn't be converted.

bool Gio::File::contains_file ( const Glib::RefPtr<File>&  descendant  )  const

Checks whether parent (recursively) contains the specified descendent .

This call does no blocking i/o.

Parameters:
descendant Input G::File.
Returns:
true if the descendent 's parent, grandparent, etc is parent . false otherwise.

std::string Gio::File::get_relative_path ( const Glib::RefPtr<File>&  descendant  )  const

Gets the path for descendant relative to parent .

This call does no blocking i/o.

Parameters:
descendant Input G::File.
Returns:
String with the relative path from descendant to parent , or 0 if descendant is not a descendant of parent . The returned string should be freed with Glib::free() when no longer needed.

Glib::RefPtr<File> Gio::File::resolve_relative_path ( const std::string relative_path  )  const

Resolves a relative path for file to an absolute path.

This call does no blocking i/o.

Parameters:
relative_path A given relative path string.
Returns:
G::File to the resolved path. 0 if relative_path is 0 or if file is invalid.

bool Gio::File::is_native (  )  const

Checks to see if a file is native to the platform.

A native file s one expressed in the platform-native filename format, e.g. "C:\Windows" or "/usr/bin/". This does not mean the file is local, as it might be on a locally mounted remote filesystem.

On some systems non-native files may be availible using the native filesystem via a userspace filesystem (FUSE), in these cases this call will return false, but g_file_get_path() will still return a native path.

This call does no blocking i/o.

Returns:
true if file is native.

bool Gio::File::has_uri_scheme ( const std::string uri_scheme  )  const

Checks to see if a G::File has a given URI scheme.

This call does no blocking i/o.

Parameters:
uri_scheme A string containing a URI scheme.
Returns:
true if G::File's backend supports the given URI scheme, false if URI scheme is 0, not supported, or G::File is invalid.

std::string Gio::File::get_uri_scheme (  )  const

Gets the URI scheme for a G::File.

RFC 3986 decodes the scheme as:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

Common schemes include "file", "http", "ftp", etc.

This call does no blocking i/o.

Returns:
A string containing the URI scheme for the given G::File. The returned string should be freed with Glib::free() when no longer needed.

Glib::RefPtr<FileInputStream> Gio::File::read ( const Glib::RefPtr<Cancellable>&  cancellable  ) 

Opens a file for reading.

The result is a G::FileInputStream that can be used to read the contents of the file.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

If the file does not exist, the G_IO_ERROR_NOT_FOUND error will be returned. If the file is a directory, the G_IO_ERROR_IS_DIRECTORY error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters:
cancellable A G::Cancellable.
error A G::Error, or 0.
Returns:
G::FileInputStream or 0 on error.

Glib::RefPtr<const FileInputStream> Gio::File::read ( const Glib::RefPtr<Cancellable>&  cancellable  )  const

Opens a file for reading.

The result is a G::FileInputStream that can be used to read the contents of the file.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

If the file does not exist, the G_IO_ERROR_NOT_FOUND error will be returned. If the file is a directory, the G_IO_ERROR_IS_DIRECTORY error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters:
cancellable A G::Cancellable.
error A G::Error, or 0.
Returns:
G::FileInputStream or 0 on error.

void Gio::File::read_async ( int  io_priority,
Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Glib::RefPtr<FileInputStream> Gio::File::read_finish ( const Glib::RefPtr<AsyncResult>&  result  ) 

Finishes an asynchronous file read operation started with g_file_read_async().

Parameters:
res A G::AsyncResult.
error A G::Error, or 0.
Returns:
A G::FileInputStream or 0 on error.

Glib::RefPtr<FileOutputStream> Gio::File::append_to ( FileCreateFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Gets an output stream for appending data to the file.

If the file doesn't already exist it is created.

By default files created are generally readable by everyone, but if you pass G::FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Some filesystems don't allow all filenames, and may return an G_IO_ERROR_INVALID_FILENAME error. If the file is a directory the G_IO_ERROR_IS_DIRECTORY error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters:
flags A set of G::FileCreateFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
A G::FileOutputStream.

Glib::RefPtr<FileOutputStream> Gio::File::create_file ( FileCreateFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Creates a new file and returns an output stream for writing to it.

The file must not already exists.

By default files created are generally readable by everyone, but if you pass G::FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

If a file with this name already exists the G_IO_ERROR_EXISTS error will be returned. If the file is a directory the G_IO_ERROR_IS_DIRECTORY error will be returned. Some filesystems don't allow all filenames, and may return an G_IO_ERROR_INVALID_FILENAME error, and if the name is to long G_IO_ERROR_FILENAME_TOO_LONG will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters:
flags A set of G::FileCreateFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
A G::FileOutputStream for the newly created file, or 0 on error.

Glib::RefPtr<FileOutputStream> Gio::File::replace ( const std::string etag,
bool  make_backup,
FileCreateFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Returns: a G::FileOutputStream or 0 on error.

Parameters:
etag An optional entity tag for the current G::File, or #0 to ignore.
make_backup true if a backup should be created.
flags A set of G::FileCreateFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
A G::FileOutputStream or 0 on error.

void Gio::File::append_to_async ( FileCreateFlags  flags,
int  io_priority,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Asynchronously opens the file for appending.

For more details, see append_to() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call append_to_finish() to get the result of the operation.

Parameters:
flags a set of FileCreateFlags.
io_priority The I/O priority of the request.
cancellable A Cancellable object which can be used to cancel the operation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::append_to_async ( FileCreateFlags  flags,
int  io_priority,
const SlotAsyncReady slot 
)

Asynchronously opens the file for appending.

For more details, see append_to() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call append_to_finish() to get the result of the operation.

Parameters:
flags a set of FileCreateFlags.
io_priority The I/O priority of the request.
slot A callback slot which will be called when the request is satisfied.

Glib::RefPtr<FileOutputStream> Gio::File::append_to_finish ( const Glib::RefPtr<AsyncResult>&  result  ) 

Finishes an asynchronous file append operation started with g_file_append_to_async().

Parameters:
res G::AsyncResult.
error A G::Error, or 0.
Returns:
A valid G::FileOutputStream or 0 on error.

void Gio::File::create_file_async ( FileCreateFlags  flags,
int  io_priority,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Asynchronously creates a new file and returns an output stream for writing to it.

The file must not already exist. For more details, see create() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call create_file_finish() to get the result of the operation.

Parameters:
flags a set of FileCreateFlags.
io_priority The I/O priority of the request.
cancellable A Cancellable object which can be used to cancel the operation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::create_file_async ( FileCreateFlags  flags,
int  io_priority,
const SlotAsyncReady slot 
)

Asynchronously creates a new file and returns an output stream for writing to it.

The file must not already exist. For more details, see create() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call create_file_finish() to get the result of the operation.

Parameters:
flags a set of FileCreateFlags.
io_priority The I/O priority of the request.
slot A callback slot which will be called when the request is satisfied.

Glib::RefPtr<FileOutputStream> Gio::File::create_file_finish ( const Glib::RefPtr<AsyncResult>&  result  ) 

Finishes an asynchronous file create operation started with g_file_create_async().

Parameters:
res A G::AsyncResult.
error A G::Error, or 0.
Returns:
A G::FileOutputStream or 0 on error.

void Gio::File::replace_async ( const std::string etag,
bool  make_backup,
FileCreateFlags  flags,
int  io_priority,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Asyncronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.

For more details, see replace() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call replace_finish() to get the result of the operation.

Parameters:
etag An entity tag for the current GFile.
make_backup true if a backup of the existing file should be made.
flags A set of FileCreateFlags.
io_priority The I/O priority of the request.
cancellable A Cancellable object which can be used to cancel the operation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::replace_async ( const std::string etag,
bool  make_backup,
FileCreateFlags  flags,
int  io_priority,
const SlotAsyncReady slot 
)

Asyncronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.

For more details, see replace() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call replace_finish() to get the result of the operation.

Parameters:
etag An entity tag for the current GFile.
make_backup true if a backup of the existing file should be made.
flags A set of FileCreateFlags.
io_priority The I/O priority of the request.
slot A callback slot which will be called when the request is satisfied.

Glib::RefPtr<FileOutputStream> Gio::File::replace_finish ( const Glib::RefPtr<AsyncResult>&  result  ) 

Finishes an asynchronous file replace operation started with g_file_replace_async().

Parameters:
res A G::AsyncResult.
error A G::Error, or 0.
Returns:
A G::FileOutputStream, or 0 on error.

Glib::RefPtr<FileInfo> Gio::File::query_info ( const std::string attributes,
FileQueryInfoFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Gets the requested information about specified file .

The result is a G::FileInfo objects that contains key-value attributes (like type or size for the file.

The attribute value is a string that specifies the file attributes that should be gathered. It is not an error if its not possible to read a particular requested attribute from a file, it just won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*" means all attributes in the standard namespace. An example attribute query be "standard::*,owner::user". The standard attributes are availible as defines, like G::FILE_ATTRIBUTE_STANDARD_NAME.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

For symlinks, normally the information about the target of the symlink is returned, rather than information about the symlink itself. However if you pass G::FILE_QUERY_INFO_NOFOLLOW_SYMLINKS in flags the information about the symlink itself will be returned. Also, for symlinks that points to non-existing files the information about the symlink itself will be returned.

If the file does not exist, the G_IO_ERROR_NOT_FOUND error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters:
attributes An attribute query string.
flags A set of G::FileQueryInfoFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error.
Returns:
A G::FileInfo for the given file , or 0 on error.

void Gio::File::query_info_async ( const std::string attributes,
FileQueryInfoFlags  flags,
int  io_priority,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Asynchronously gets the requested information about specified file.

The result is a FileInfo object that contains key-value attributes (such as type or size for the file).

For more details, see query_info(() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call query_info_finish() to get the result of the operation.

Parameters:
attributes An attribute query string.
flags A set of FileQueryInfoFlags.
io_priority The I/O priority of the request.
cancellable A Cancellable object which can be used to cancel the operation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::query_info_async ( const std::string attributes,
FileQueryInfoFlags  flags,
int  io_priority,
const SlotAsyncReady slot 
)

Asynchronously gets the requested information about specified file.

The result is a FileInfo object that contains key-value attributes (such as type or size for the file).

For more details, see query_info(() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call query_info_finish() to get the result of the operation.

Parameters:
attributes An attribute query string.
flags A set of FileQueryInfoFlags.
io_priority The I/O priority of the request.
slot A callback slot which will be called when the request is satisfied.

Glib::RefPtr<FileInfo> Gio::File::query_info_finish ( const Glib::RefPtr<AsyncResult>&  result  ) 

Finishes an asynchronous file info query.

See g_file_query_info_async().

Parameters:
res A G::AsyncResult.
error A G::Error.
Returns:
G::FileInfo for given file or 0 on error.

Glib::RefPtr<FileInfo> Gio::File::query_filesystem_info ( const std::string attributes,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Similar to g_file_query_info(), but obtains information about the filesystem the file is on, rather than the file itself.

For instance the amount of space availible and the type of the filesystem.

The attribute value is a string that specifies the file attributes that should be gathered. It is not an error if its not possible to read a particular requested attribute from a file, it just won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "fs:*" means all attributes in the fs namespace. The standard namespace for filesystem attributes is "fs". Common attributes of interest are G::FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem in bytes), G::FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes availible), and G::FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem).

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

If the file does not exist, the G_IO_ERROR_NOT_FOUND error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters:
attributes An attribute query string.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error.
Returns:
A G::FileInfo or 0 if there was an error.

Glib::RefPtr<FileEnumerator> Gio::File::enumerate_children ( const std::string attributes,
FileQueryInfoFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Gets the requested information about the files in a directory.

The result is a G::FileEnumerator object that will give out G::FileInfo objects for all the files in the directory.

The attribute value is a string that specifies the file attributes that should be gathered. It is not an error if its not possible to read a particular requested attribute from a file, it just won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*" means all attributes in the standard namespace. An example attribute query be "standard::*,owner::user". The standard attributes are availible as defines, like G::FILE_ATTRIBUTE_STANDARD_NAME.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

If the file does not exist, the G_IO_ERROR_NOT_FOUND error will be returned. If the file is not a directory, the G_FILE_ERROR_NOTDIR error will be returned. Other errors are possible too.

Parameters:
attributes An attribute query string.
flags A set of G::FileQueryInfoFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error G::Error for error reporting.
Returns:
A G::FileEnumerator if successful, 0 on error.

void Gio::File::enumerate_children_async ( const std::string attributes,
FileQueryInfoFlags  flags,
int  io_priority,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Asynchronously gets the requested information about the files in a directory.

The result is a GFileEnumerator object that will give out GFileInfo objects for all the files in the directory.

For more details, see enumerate_children() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call enumerate_children_finish() to get the result of the operation.

Parameters:
attributes An attribute query string.
flags A set of FileQueryInfoFlags.
io_priority The I/O priority of the request.
cancellable A Cancellable object which can be used to cancel the operation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::enumerate_children_async ( const std::string attributes,
FileQueryInfoFlags  flags,
int  io_priority,
const SlotAsyncReady slot 
)

Asynchronously gets the requested information about the files in a directory.

The result is a GFileEnumerator object that will give out GFileInfo objects for all the files in the directory.

For more details, see enumerate_children() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call enumerate_children_finish() to get the result of the operation.

Parameters:
attributes An attribute query string.
flags A set of FileQueryInfoFlags.
io_priority The I/O priority of the request.
slot A callback slot which will be called when the request is satisfied.

Glib::RefPtr<FileEnumerator> Gio::File::enumerate_children_finish ( const Glib::RefPtr<AsyncResult>&  result  ) 

Finishes an async enumerate children operation.

See g_file_enumerate_children_async().

Parameters:
res A G::AsyncResult.
error A G::Error.
Returns:
A G::FileEnumerator or 0 if an error occurred.

Glib::RefPtr<File> Gio::File::set_display_name ( const std::string display_name,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Renames file to the specified display name.

The display name is converted from UTF8 to the correct encoding for the target filesystem if possible and the file is renamed to this.

If you want to implement a rename operation in the user interface the edit name (G::FILE_ATTRIBUTE_STANDARD_EDIT_NAME) should be used as the initial value in the rename widget, and then the result after editing should be passed to g_file_set_display_name().

On success the resulting converted filename is returned.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
display_name A string.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
A G::File specifying what file was renamed to, or 0 if there was an error.

void Gio::File::set_display_name_async ( const std::string display_name,
int  io_priority,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Asynchronously sets the display name for a given Gio::File.

For the synchronous version of this function, see set_display_name(). When the operation is finished, slot will be called. You can then call set_display_name_finish() to get the result of the operation.

Parameters:
display_name A string.
io_priority The I/O priority of the request.
cancellable A Cancellable object which can be used to cancel the operation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::set_display_name_async ( const std::string display_name,
int  io_priority,
const SlotAsyncReady slot 
)

Asynchronously sets the display name for a given Gio::File.

For the synchronous version of this function, see set_display_name(). When the operation is finished, slot will be called. You can then call set_display_name_finish() to get the result of the operation.

Parameters:
display_name A string.
io_priority The I/O priority of the request.
slot A callback slot which will be called when the request is satisfied.

Glib::RefPtr<File> Gio::File::set_display_name_finish ( const Glib::RefPtr<AsyncResult>&  result  ) 

Finishes setting a display name started with g_file_set_display_name_async().

Parameters:
res A G::AsyncResult.
error A G::Error, or 0.
Returns:
A G::File or 0 on error.

bool Gio::File::remove ( const Glib::RefPtr<Cancellable>&  cancellable  ) 

Deletes a file.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true if the file was deleted. false otherwise.

bool Gio::File::trash ( const Glib::RefPtr<Cancellable>&  cancellable  ) 

Sends file to the "Trashcan", if possible.

This is similar to deleting it, but the user can recover it before emptying the trashcan. Not all filesystems support trashing, so this call can return the G::IO_ERROR_NOT_SUPPORTED error.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true on successful trash, false otherwise.

bool Gio::File::copy ( const Glib::RefPtr<File>&  destination,
FileCopyFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotFileProgress slot 
)

bool Gio::File::copy ( const Glib::RefPtr<File>&  destination,
FileCopyFlags  flags,
const SlotFileProgress slot 
)

bool Gio::File::move ( const Glib::RefPtr<File>&  destination,
FileCopyFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotFileProgress slot 
)

bool Gio::File::move ( const Glib::RefPtr<File>&  destination,
FileCopyFlags  flags,
const SlotFileProgress slot 
)

bool Gio::File::make_directory ( const Glib::RefPtr<Cancellable>&  cancellable  ) 

Creates a directory.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true on successful creation, false otherwise.

bool Gio::File::make_symbolic_link ( const std::string symlink_value,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Creates a symbolic link.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
symlink_value A string with the value of the new symlink.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error.
Returns:
true on the creation of a new symlink, false otherwise.

Glib::RefPtr<FileAttributeInfoList> Gio::File::query_settable_attributes ( const Glib::RefPtr<Cancellable>&  cancellable  ) 

Obtain the list of settable attributes for the file.

Returns: a G::FileAttributeInfoList describing the settable attributes.

Parameters:
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
A G::FileAttributeInfoList describing the settable attributes. When you are done with it, release it with g_file_attribute_info_list_unref().

Glib::RefPtr<FileAttributeInfoList> Gio::File::query_writable_namespaces ( const Glib::RefPtr<Cancellable>&  cancellable  ) 

Obtain the list of attribute namespaces where new attributes can be created by a user.

An example of this is extended attributes (in the "xattr" namespace).

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
A G::FileAttributeInfoList describing the writable namespaces. When you are done with it, release it with g_file_attribute_info_list_unref().

bool Gio::File::set_attributes_from_info ( const Glib::RefPtr<FileInfo>&  info,
FileQueryInfoFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Tries to set all attributes in the G::FileInfo on the target values, not stopping on the first error.

If there is any error during this operation then error will be set to the first error. Error on particular fields are flagged by setting the "status" field in the attribute value to G::FILE_ATTRIBUTE_STATUS_ERROR_SETTING, which means you can also detect further errors.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
info A G::FileInfo.
flags G::FileQueryInfoFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true if there was any error, false otherwise.

void Gio::File::set_attributes_async ( const Glib::RefPtr<FileInfo>&  info,
FileQueryInfoFlags  flags,
int  io_priority,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Asynchronously sets the attributes of file with info.

For more details, see set_attributes_from_info() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call set_attributes_finish() to get the result of the operation.

Parameters:
info A FileInfo.
flags A set of FileQueryInfoFlags.
io_priority The I/O priority of the request.
cancellable A Cancellable object which can be used to cancel the operation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::set_attributes_async ( const Glib::RefPtr<FileInfo>&  info,
FileQueryInfoFlags  flags,
int  io_priority,
const SlotAsyncReady slot 
)

Asynchronously sets the attributes of file with info.

For more details, see set_attributes_from_info() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call set_attributes_finish() to get the result of the operation.

Parameters:
info A FileInfo.
flags A set of FileQueryInfoFlags.
io_priority The I/O priority of the request.
slot A callback slot which will be called when the request is satisfied.

bool Gio::File::set_attributes_finish ( const Glib::RefPtr<AsyncResult>&  result,
const Glib::RefPtr<FileInfo>&  info 
)

bool Gio::File::set_attribute_string ( const std::string attribute,
const std::string value,
FileQueryInfoFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Sets attribute of type G::FILE_ATTRIBUTE_TYPE_STRING to value .

If attribute is of a different type, this operation will fail.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
attribute A string containing the attribute's name.
value A string containing the attribute's value.
flags G::FileQueryInfoFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true if the attribute was successfully set, false otherwise.

bool Gio::File::set_attribute_byte_string ( const std::string attribute,
const std::string value,
FileQueryInfoFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Sets attribute of type G::FILE_ATTRIBUTE_TYPE_BYTE_STRING to value .

If attribute is of a different type, this operation will fail, returning false.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
attribute A string containing the attribute's name.
value A string containing the attribute's new value.
flags A G::FileQueryInfoFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true if the attribute was successfully set to value in the file , false otherwise.

bool Gio::File::set_attribute_uint32 ( const std::string attribute,
guint32  value,
FileQueryInfoFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Sets attribute of type G::FILE_ATTRIBUTE_TYPE_UINT32 to value .

If attribute is of a different type, this operation will fail.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
attribute A string containing the attribute's name.
value A guint32 containing the attribute's new value.
flags A G::FileQueryInfoFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true if the attribute was successfully set to value in the file , false otherwise.

bool Gio::File::set_attribute_int32 ( const std::string attribute,
gint32  value,
FileQueryInfoFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Sets attribute of type G::FILE_ATTRIBUTE_TYPE_INT32 to value .

If attribute is of a different type, this operation will fail.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
attribute A string containing the attribute's name.
value A gint32 containing the attribute's new value.
flags A G::FileQueryInfoFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true if the attribute was successfully set to value in the file , false otherwise.

bool Gio::File::set_attribute_uint64 ( const std::string attribute,
guint64  value,
FileQueryInfoFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Sets attribute of type G::FILE_ATTRIBUTE_TYPE_UINT64 to value .

If attribute is of a different type, this operation will fail.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
attribute A string containing the attribute's name.
value A guint64 containing the attribute's new value.
flags A G::FileQueryInfoFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true if the attribute was successfully set to value in the file , false otherwise.

bool Gio::File::set_attribute_int64 ( const std::string attribute,
gint64  value,
FileQueryInfoFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Sets attribute of type G::FILE_ATTRIBUTE_TYPE_INT64 to value .

If attribute is of a different type, this operation will fail.

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
attribute A string containing the attribute's name.
value A guint64 containing the attribute's new value.
flags A G::FileQueryInfoFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true if the attribute was successfully set, false otherwise.

void Gio::File::mount_mountable ( const Glib::RefPtr<MountOperation>&  mount_operation,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Mounts a file of type FILE_TYPE_MOUNTABLE.

Using mount_operation, you can request callbacks when, for instance, passwords are needed during authentication.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.

When the operation is finished, slot will be called. You can then call mount_mountable_finish() to get the result of the operation.

Parameters:
flags Flags affecting the operation.
mount_operation A MountOperation.
cancellable A Cancellable object which can be used to cancel the operation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::mount_mountable ( const Glib::RefPtr<MountOperation>&  mount_operation,
const SlotAsyncReady slot 
)

Mounts a file of type FILE_TYPE_MOUNTABLE.

Using mount_operation, you can request callbacks when, for instance, passwords are needed during authentication.

When the operation is finished, slot will be called. You can then call mount_mountable_finish() to get the result of the operation.

Parameters:
flags Flags affecting the operation.
mount_operation A MountOperation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::mount_mountable ( const SlotAsyncReady slot  ) 

Mounts a file of type FILE_TYPE_MOUNTABLE without user interaction.

When the operation is finished, slot will be called. You can then call mount_mountable_finish() to get the result of the operation.

Parameters:
flags Flags affecting the operation.
slot A callback slot which will be called when the request is satisfied.

Glib::RefPtr<File> Gio::File::mount_mountable_finish ( const Glib::RefPtr<AsyncResult>&  result  ) 

Finishes a mount operation.

See g_file_mount_mountable() for details.

Finish an asynchronous mount operation that was started with g_file_mount_mountable().

Parameters:
result A G::AsyncResult.
error A G::Error, or 0.
Returns:
A G::File or 0 on error.

void Gio::File::unmount_mountable ( GMountUnmountFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Unmounts a file of type FILE_TYPE_MOUNTABLE.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.

When the operation is finished, slot will be called. You can then call unmount_mountable_finish() to get the result of the operation.

Parameters:
flags Flags affecting the operation.
cancellable A Cancellable object which can be used to cancel the operation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::unmount_mountable ( GMountUnmountFlags  flags,
const SlotAsyncReady slot 
)

Unmounts a file of type FILE_TYPE_MOUNTABLE.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.

When the operation is finished, slot will be called. You can then call unmount_mountable_finish() to get the result of the operation.

Parameters:
flags Flags affecting the operation.
slot A callback slot which will be called when the request is satisfied.

bool Gio::File::unmount_mountable_finish ( const Glib::RefPtr<AsyncResult>&  result  ) 

Finishes an unmount operation, see g_file_unmount_mountable() for details.

Finish an asynchronous unmount operation that was started with g_file_unmount_mountable().

Parameters:
result A G::AsyncResult.
error A G::Error, or 0.
Returns:
true if the operation finished successfully. false otherwise.

void Gio::File::eject_mountable ( GMountUnmountFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

Starts an asynchronous eject on a mountable.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.

When the operation is finished, slot will be called. You can then call eject_mountable_finish() to get the result of the operation.

Parameters:
flags Flags affecting the operation.
cancellable A Cancellable object which can be used to cancel the operation.
slot A callback slot which will be called when the request is satisfied.

void Gio::File::eject_mountable ( GMountUnmountFlags  flags,
const SlotAsyncReady slot 
)

Starts an asynchronous eject on a mountable.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.

When the operation is finished, slot will be called. You can then call eject_mountable_finish() to get the result of the operation.

Parameters:
flags Flags affecting the operation.
slot A callback slot which will be called when the request is satisfied.

bool Gio::File::eject_mountable_finish ( const Glib::RefPtr<AsyncResult>&  result  ) 

Finishes an asynchronous eject operation started by g_file_eject_mountable().

Parameters:
result A G::AsyncResult.
error A G::Error, or 0.
Returns:
true if the file was ejected successfully. false otherwise.

bool Gio::File::load_contents ( const Glib::RefPtr<Cancellable>&  cancellable,
char **  contents,
gsize &  length,
char **  etag_out 
)

Loads the content of the file into memory, returning the size of the data.

The data is always zero terminated, but this is not included in the resultant length .

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

Parameters:
cancellable Optional G::Cancellable object, 0 to ignore.
contents A location to place the contents of the file.
length A location to place the length of the contents of the file.
etag_out A location to place the current entity tag for the file.
error A G::Error, or 0.
Returns:
true if the file 's contents were successfully loaded. false if there were errors..

void Gio::File::load_contents_async ( const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

void Gio::File::load_contents_async ( const SlotAsyncReady slot  ) 

bool Gio::File::load_contents_finish ( const Glib::RefPtr<AsyncResult>&  result,
char **  contents,
gsize &  length,
char **  etag_out 
)

Finishes an asynchronous load of the file 's contents.

The contents are placed in contents , and length is set to the size of the contents string. If etag_out is present, it will be set to the new entity tag for the file .

Parameters:
res A G::AsyncResult.
contents A location to place the contents of the file.
length A location to place the length of the contents of the file.
etag_out A location to place the current entity tag for the file.
error A G::Error, or 0.
Returns:
true if the load was successful. If false and error is present, it will be set appropriately.

void Gio::File::load_partial_contents_async ( const Glib::RefPtr<Cancellable>&  cancellable,
const SlotReadMore slot_read_more,
const SlotAsyncReady slot_async_ready 
)

Reads the partial contents of a file.

The slot_read_more callback slot should be used to stop reading from the file when appropriate. This operation can be finished by load_partial_contents_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.

When the operation is finished, slot will be called. You can then call load_partial_contents_finish() to get the result of the operation.

Parameters:
cancellable A Cancellable object which can be used to cancel the operation.
slot_read_more A callback to receive partial data and to specify whether further data should be read.
slot_async_ready A callback slot which will be called when the request is satisfied.

void Gio::File::load_partial_contents_async ( const SlotReadMore slot_read_more,
const SlotAsyncReady slot_async_ready 
)

Reads the partial contents of a file.

The slot_read_more callback slot should be used to stop reading from the file when appropriate. This operation can be finished by load_partial_contents_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.

When the operation is finished, slot will be called. You can then call load_partial_contents_finish() to get the result of the operation.

Parameters:
slot_read_more A callback to receive partial data and to specify whether further data should be read.
slot_async_ready A callback slot which will be called when the request is satisfied.

bool Gio::File::load_partial_contents_finish ( const Glib::RefPtr<AsyncResult>&  result,
char **  contents,
gsize &  length,
char **  etag_out 
)

Finishes an asynchronous partial load operation that was started with g_file_load_partial_contents_async().

Parameters:
res A G::AsyncResult.
contents A location to place the contents of the file.
length A location to place the length of the contents of the file.
etag_out A location to place the current entity tag for the file.
error A G::Error, or 0.
Returns:
true if the load was successful. If false and error is present, it will be set appropriately.

void Gio::File::replace_contents ( const char *  contents,
gsize  length,
const char *  etag,
bool  make_backup,
FileCreateFlags  flags,
char **  new_etag,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Replaces the contents of file with contents of length bytes.

If etag is specified (not 0) any existing file must have that etag, or the error G::IO_ERROR_WRONG_ETAG will be returned.

If make_backup is true, this function will attempt to make a backup of file .

If cancellable is not 0, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G::IO_ERROR_CANCELLED will be returned.

The returned new_etag can be used to verify that the file hasn't changed the next time it is saved over.

Parameters:
contents A string containing the new contents for file .
length The length of contents in bytes.
etag The old entity tag for the document.
make_backup true if a backup should be created.
flags A set of G::FileCreateFlags.
new_etag A location to a new entity tag for the document.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, or 0.
Returns:
true if successful. If an error has occured, this function will return false and set error appropriately if present.

void Gio::File::replace_contents_async ( const char *  contents,
gsize  length,
const char *  etag,
bool  make_backup,
FileCreateFlags  flags,
const Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

void Gio::File::replace_contents_async ( const char *  contents,
gsize  length,
const char *  etag,
bool  make_backup,
FileCreateFlags  flags,
const SlotAsyncReady slot 
)

void Gio::File::replace_contents_finish ( const Glib::RefPtr<AsyncResult>&  result,
char **  new_etag 
)

Finishes an asynchronous replace of the given file .

See g_file_replace_contents_async(). Sets new_etag to the new entity tag for the document, if present.

Parameters:
res A G::AsyncResult.
new_etag A location of a new entity tag for the document.
error A G::Error, or 0.
Returns:
true on success, false on failure.

virtual Glib::RefPtr<File> Gio::File::dup_vfunc (  )  [virtual]

virtual guint Gio::File::hash_vfunc (  )  const [virtual]

virtual std::string Gio::File::get_basename_vfunc (  )  const [virtual]

virtual std::string Gio::File::get_path_vfunc (  )  const [virtual]

virtual std::string Gio::File::get_uri_vfunc (  )  const [virtual]

virtual std::string Gio::File::get_parse_name_vfunc (  )  const [virtual]

virtual Glib::RefPtr<File> Gio::File::get_parent_vfunc (  )  const [virtual]

virtual bool Gio::File::contains_file_vfunc ( const Glib::RefPtr<File>&  descendant  )  const [virtual]

virtual std::string Gio::File::get_relative_path_vfunc ( const Glib::RefPtr<File>&  descendant  )  const [virtual]

virtual Glib::RefPtr<File> Gio::File::resolve_relative_path_vfunc ( const std::string relative_path  )  const [virtual]

virtual bool Gio::File::is_native_vfunc (  )  const [virtual]

virtual bool Gio::File::has_uri_scheme_vfunc ( const std::string uri_scheme  )  const [virtual]


Friends And Related Function Documentation

bool operator== ( const Glib::RefPtr<File>&  lhs,
const Glib::RefPtr<File>&  rhs 
) [related]

bool operator!= ( const Glib::RefPtr<File>&  lhs,
const Glib::RefPtr<File>&  rhs 
) [related]

Glib::RefPtr<Gio::File> wrap ( GFile *  object,
bool  take_copy = false 
) [related]

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

Parameters:
object The C instance.
take_copy False 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:

Generated for glibmm 2.4 by Doxygen 1.5.1 © 1997-2001