Module: Gio::File
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/gio2/file.rb,
lib/gio2/deprecated.rb
Overview
GFile is a high level abstraction for manipulating files on a
virtual file system. GFiles are lightweight, immutable objects
that do no I/O upon creation. It is necessary to understand that
GFile objects do not represent files, merely an identifier for a
file. All file content I/O is implemented as streaming operations
(see [classGio.InputStream] and [classGio.OutputStream]).
To construct a GFile, you can use:
- [funcGio.File.new_for_path] if you have a path.
- [funcGio.File.new_for_uri] if you have a URI.
- [funcGio.File.new_for_commandline_arg] or [funcGio.File.new_for_commandline_arg_and_cwd] for a command line argument.
- [funcGio.File.new_tmp] to create a temporary file from a template.
- [funcGio.File.new_tmp_async] to asynchronously create a temporary file.
- [funcGio.File.new_tmp_dir_async] to asynchronously create a temporary directory.
- [funcGio.File.parse_name] from a UTF-8 string gotten from [methodGio.File.get_parse_name].
- [funcGio.File.new_build_filename] or [funcGio.File.new_build_filenamev] to create a file from path elements.
One way to think of a GFile is as an abstraction of a pathname. For
normal files the system pathname is what is stored internally, but as
GFiles are extensible it could also be something else that corresponds
to a pathname in a userspace implementation of a filesystem.
GFiles make up hierarchies of directories and files that correspond to
the files on a filesystem. You can move through the file system with
GFile using [methodGio.File.get_parent] to get an identifier for the
parent directory, [methodGio.File.get_child] to get a child within a
directory, and [methodGio.File.resolve_relative_path] to resolve a relative
path between two GFiles. There can be multiple hierarchies, so you may not
end up at the same root if you repeatedly call [methodGio.File.get_parent]
on two different files.
All GFiles have a basename (get with [methodGio.File.get_basename]). These
names are byte strings that are used to identify the file on the filesystem
(relative to its parent directory) and there is no guarantees that they
have any particular charset encoding or even make any sense at all. If
you want to use filenames in a user interface you should use the display
name that you can get by requesting the
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with
[methodGio.File.query_info]. This is guaranteed to be in UTF-8 and can be
used in a user interface. But always store the real basename or the GFile
to use to actually access the file, because there is no way to go from a
display name to the actual name.
Using GFile as an identifier has the same weaknesses as using a path
in that there may be multiple aliases for the same file. For instance,
hard or soft links may cause two different GFiles to refer to the same
file. Other possible causes for aliases are: case insensitive filesystems,
short and long names on FAT/NTFS, or bind mounts in Linux. If you want to
check if two GFiles point to the same file you can query for the
G_FILE_ATTRIBUTE_ID_FILE attribute. Note that GFile does some trivial
canonicalization of pathnames passed in, so that trivial differences in
the path string used at creation (duplicated slashes, slash at end of
path, . or .. path segments, etc) does not create different GFiles.
Many GFile 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 [callbackGio.AsyncReadyCallback] which is then used to
finalize the operation, producing a [ifaceGio.AsyncResult] which is then
passed to the function’s matching _finish() operation.
It is highly recommended to use asynchronous calls when running within a shared main loop, such as in the main thread of an application. This avoids I/O operations blocking other sources on the main loop from being dispatched. Synchronous I/O operations should be performed from worker threads. See the introduction to asynchronous programming section for more.
Some GFile operations almost always take a noticeable amount of time, and
so do not have synchronous analogs. Notable cases include:
- [methodGio.File.mount_mountable] to mount a mountable file.
- [methodGio.File.unmount_mountable_with_operation] to unmount a mountable file.
- [methodGio.File.eject_mountable_with_operation] to eject a mountable file.
Entity Tags
One notable feature of GFiles 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.
Class Method Summary collapse
Instance Method Summary collapse
- #_query_settable_attributes_async ⇒ nil
- #_query_settable_attributes_finish ⇒ nil
- #_query_writable_namespaces_async ⇒ nil
- #_query_writable_namespaces_finish ⇒ nil
-
#append_to(file, flags, cancellable) ⇒ Gio::FileOutputStream
A GFile::OutputStream, or nil on error.
- #append_to_async(file, flags, io_priority, cancellable, callback, user_data) ⇒ nil
-
#append_to_finish(file, res) ⇒ Gio::FileOutputStream
A valid GFile::OutputStream or nil on error.
-
#basename ⇒ Gio::filename
Gets the base name (the last component of the path) for a given #GFile.
-
#build_attribute_list_for_copy(flags, cancellable) ⇒ String
Prepares the file attribute query string for copying to file.
-
#copy(source, destination, flags, cancellable, progress_callback, progress_callback_data) ⇒ Boolean
True on success, false otherwise.
- #copy_async(source, destination, flags, io_priority, cancellable, progress_callback, progress_callback_data, callback, user_data) ⇒ nil
-
#copy_attributes(destination, flags, cancellable) ⇒ Boolean
Copies the file attributes from source to destination.
-
#copy_finish(file, res) ⇒ Boolean
A true on success, false on error.
-
#create(file, flags, cancellable) ⇒ Gio::FileOutputStream
A GFile::OutputStream for the newly created file, or nil on error.
- #create_async(file, flags, io_priority, cancellable, callback, user_data) ⇒ nil
-
#create_finish(file, res) ⇒ Gio::FileOutputStream
A GFile::OutputStream or nil on error.
-
#create_readwrite(file, flags, cancellable) ⇒ Gio::FileIOStream
A GFile::IOStream for the newly created file, or nil on error.
- #create_readwrite_async(file, flags, io_priority, cancellable, callback, user_data) ⇒ nil
-
#create_readwrite_finish(file, res) ⇒ Gio::FileIOStream
A GFile::IOStream or nil on error.
-
#delete(cancellable) ⇒ Boolean
Deletes a file.
-
#delete_async(io_priority, cancellable, callback, user_data) ⇒ nil
Asynchronously delete a file.
-
#delete_file(file, cancellable) ⇒ Boolean
True if the file was deleted.
- #delete_file_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
-
#delete_file_finish(file, result) ⇒ Boolean
True if the file was deleted.
-
#delete_finish(result) ⇒ Boolean
Finishes deleting a file started with g_file_delete_async().
-
#display_name_finish=(res) ⇒ Gio::File
Finishes setting a display name started with g_file_set_display_name_async().
-
#dup(file) ⇒ Gio::File
A new #GFile that is a duplicate of the given #GFile.
- #eject_mountable(file, flags, cancellable, callback, user_data) ⇒ nil
-
#eject_mountable_finish(file, result) ⇒ Boolean
True if the file was ejected successfully.
- #eject_mountable_with_operation(file, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
-
#eject_mountable_with_operation_finish(file, result) ⇒ Boolean
True if the file was ejected successfully.
-
#enumerate_children(file, attributes, flags, cancellable) ⇒ Gio::FileEnumerator
A GFile::Enumerator if successful, nil on error.
- #enumerate_children_async(file, attributes, flags, io_priority, cancellable, callback, user_data) ⇒ nil
-
#enumerate_children_finish(file, res) ⇒ Gio::FileEnumerator
A GFile::Enumerator or nil if an error occurred.
-
#equal(file1, file2) ⇒ Boolean
True if file1 and file2 are equal.
-
#find_enclosing_mount(file, cancellable) ⇒ Gio::Mount
A #GMount where the file is located or nil on error.
- #find_enclosing_mount_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
-
#find_enclosing_mount_finish(file, res) ⇒ Gio::Mount
#GMount for given file or nil on error.
-
#get_basename(file) ⇒ Gio::filename
String containing the #GFile's base name, or nil if given #GFile is invalid.
-
#get_child(name) ⇒ Gio::File
Gets a child of file with basename equal to name.
-
#get_child_for_display_name(file, display_name) ⇒ Gio::File
A #GFile to the specified child, or nil if the display name couldn't be converted.
-
#get_parent(file) ⇒ Gio::File
A #GFile structure to the parent of the given #GFile or nil if there is no parent.
-
#get_parse_name(file) ⇒ String
A string containing the #GFile's parse name.
-
#get_path(file) ⇒ Gio::filename
String containing the #GFile's path, or nil if no such path exists.
-
#get_relative_path(parent, descendant) ⇒ Gio::filename
String with the relative path from descendant to parent, or nil if descendant doesn't have parent as prefix.
-
#get_uri(file) ⇒ String
A string containing the #GFile's URI.
-
#get_uri_scheme(file) ⇒ String
A string containing the URI scheme for the given #GFile or nil if the #GFile was constructed with an invalid URI.
-
#has_parent(parent) ⇒ Boolean
Checks if file has a parent, and optionally, if it is parent.
-
#has_prefix(prefix) ⇒ Boolean
Checks whether file has the prefix specified by prefix.
-
#has_uri_scheme(file, uri_scheme) ⇒ Boolean
True if #GFile's backend supports the given URI scheme, false if URI scheme is nil, not supported, or #GFile is invalid.
-
#hash(file) ⇒ Integer
0 if file is not a valid #GFile, otherwise an integer that can be used as hash value for the #GFile.
-
#is_native(file) ⇒ Boolean
True if file is native.
-
#load_bytes(cancellable, etag_out) ⇒ GLib::Bytes
Loads the contents of file and returns it as #GBytes.
-
#load_bytes_async(cancellable, callback, user_data) ⇒ nil
Asynchronously loads the contents of file as #GBytes.
-
#load_bytes_finish(result, etag_out) ⇒ GLib::Bytes
Completes an asynchronous request to g_file_load_bytes_async().
-
#load_contents(cancellable, contents, length, etag_out) ⇒ Boolean
Loads the content of the file into memory.
-
#load_contents_async(cancellable, callback, user_data) ⇒ nil
Starts an asynchronous load of the file's contents.
-
#load_contents_finish(res, contents, length, etag_out) ⇒ Boolean
Finishes an asynchronous load of the file's contents.
-
#load_partial_contents_async(cancellable, read_more_callback, callback, user_data) ⇒ nil
Reads the partial contents of a file.
-
#load_partial_contents_finish(res, contents, length, etag_out) ⇒ Boolean
Finishes an asynchronous partial load operation that was started with g_file_load_partial_contents_async().
-
#make_directory(file, cancellable) ⇒ Boolean
True on successful creation, false otherwise.
- #make_directory_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
-
#make_directory_finish(file, result) ⇒ Boolean
True on successful directory creation, false otherwise.
-
#make_directory_with_parents(cancellable) ⇒ Boolean
Creates a directory and any parent directories that may not exist similar to 'mkdir -p'.
-
#make_symbolic_link(file, symlink_value, cancellable) ⇒ Boolean
True on the creation of a new symlink, false otherwise.
- #make_symbolic_link_async(file, symlink_value, io_priority, cancellable, callback, user_data) ⇒ nil
-
#make_symbolic_link_finish(file, result) ⇒ Boolean
True on successful directory creation, false otherwise.
-
#measure_disk_usage(file, flags, cancellable, progress_callback, progress_data, disk_usage, num_dirs, num_files) ⇒ Boolean
True if successful, with the out parameters set.
- #measure_disk_usage_async(file, flags, io_priority, cancellable, progress_callback, progress_data, callback, user_data) ⇒ nil
-
#measure_disk_usage_finish(file, result, disk_usage, num_dirs, num_files) ⇒ Boolean
True if successful, with the out parameters set.
-
#monitor(flags, cancellable) ⇒ Gio::FileMonitor
Obtains a file or directory monitor for the given file, depending on the type of the file.
-
#monitor_dir(file, flags, cancellable) ⇒ Gio::FileMonitor
A GFile::Monitor for the given file, or nil on error.
-
#monitor_directory(flags, cancellable) ⇒ Gio::FileMonitor
Obtains a directory monitor for the given file.
-
#monitor_file(file, flags, cancellable) ⇒ Gio::FileMonitor
A GFile::Monitor for the given file, or nil on error.
- #mount_enclosing_volume(location, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
-
#mount_enclosing_volume_finish(location, result) ⇒ Boolean
True if successful.
- #mount_mountable(file, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
-
#mount_mountable_finish(file, result) ⇒ Gio::File
A #GFile or nil on error.
-
#move(source, destination, flags, cancellable, progress_callback, progress_callback_data) ⇒ Boolean
True on successful move, false otherwise.
- #move_async(source, destination, flags, io_priority, cancellable, progress_callback, progress_callback_data, callback, user_data) ⇒ nil
-
#move_finish(file, result) ⇒ Boolean
True on successful file move, false otherwise.
-
#open_readwrite(file, cancellable) ⇒ Gio::FileIOStream
GFile::IOStream or nil on error.
- #open_readwrite_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
-
#open_readwrite_finish(file, res) ⇒ Gio::FileIOStream
A GFile::IOStream or nil on error.
-
#parent ⇒ Gio::File
Gets the parent directory for the file.
-
#parse_name ⇒ String
Gets the parse name of the file.
-
#path ⇒ Gio::filename
Gets the local pathname for #GFile, if one exists.
-
#peek_path ⇒ Gio::filename
Exactly like g_file_get_path(), but caches the result via g_object_set_qdata_full().
- #poll_mountable(file, cancellable, callback, user_data) ⇒ nil
-
#poll_mountable_finish(file, result) ⇒ Boolean
otherwise.
-
#prefix_matches(prefix, file) ⇒ Boolean
True if the file's parent, grandparent, etc is prefix, false otherwise.
-
#query_default_handler(cancellable) ⇒ Gio::AppInfo
Returns the GApp::Info that is registered as the default application to handle the file specified by file.
-
#query_default_handler_async(io_priority, cancellable, callback, user_data) ⇒ nil
Async version of g_file_query_default_handler().
-
#query_default_handler_finish(result) ⇒ Gio::AppInfo
Finishes a g_file_query_default_handler_async() operation.
-
#query_exists(cancellable) ⇒ Boolean
Utility function to check if a particular file exists.
-
#query_file_type(flags, cancellable) ⇒ Gio::FileType
Utility function to inspect the GFile::Type of a file.
-
#query_filesystem_info(file, attributes, cancellable) ⇒ Gio::FileInfo
A GFile::Info or nil if there was an error.
- #query_filesystem_info_async(file, attributes, io_priority, cancellable, callback, user_data) ⇒ nil
-
#query_filesystem_info_finish(file, res) ⇒ Gio::FileInfo
GFile::Info for given file or nil on error.
-
#query_info(file, attributes, flags, cancellable) ⇒ Gio::FileInfo
A GFile::Info for the given file, or nil on error.
- #query_info_async(file, attributes, flags, io_priority, cancellable, callback, user_data) ⇒ nil
-
#query_info_finish(file, res) ⇒ Gio::FileInfo
GFile::Info for given file or nil on error.
-
#query_settable_attributes(file, cancellable) ⇒ Gio::FileAttributeInfoList
A GFile::AttributeInfoList describing the settable attributes.
-
#query_writable_namespaces(file, cancellable) ⇒ Gio::FileAttributeInfoList
A GFile::AttributeInfoList describing the writable namespaces.
-
#read(cancellable = nil) ⇒ Gio::FileInputStream
Opens a file for reading.
- #read_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
-
#read_finish(file, res) ⇒ Gio::FileInputStream
A GFile::InputStream or nil on error.
-
#read_fn(file, cancellable) ⇒ Gio::FileInputStream
GFile::InputStream or nil on error.
-
#read_raw ⇒ Gio::FileInputStream
Opens a file for reading.
-
#replace(file, etag, make_backup, flags, cancellable) ⇒ Gio::FileOutputStream
A GFile::OutputStream or nil on error.
- #replace_async(file, etag, make_backup, flags, io_priority, cancellable, callback, user_data) ⇒ nil
-
#replace_contents(contents, length, etag, make_backup, flags, new_etag, cancellable) ⇒ Boolean
Replaces the contents of file with contents of length bytes.
-
#replace_contents_async(contents, length, etag, make_backup, flags, cancellable, callback, user_data) ⇒ nil
Starts an asynchronous replacement of file with the given contents of length bytes.
-
#replace_contents_bytes_async(contents, etag, make_backup, flags, cancellable, callback, user_data) ⇒ nil
Same as g_file_replace_contents_async() but takes a #GBytes input instead.
-
#replace_contents_finish(res, new_etag) ⇒ Boolean
Finishes an asynchronous replace of the given file.
-
#replace_finish(file, res) ⇒ Gio::FileOutputStream
A GFile::OutputStream, or nil on error.
-
#replace_readwrite(file, etag, make_backup, flags, cancellable) ⇒ Gio::FileIOStream
A GFile::IOStream or nil on error.
- #replace_readwrite_async(file, etag, make_backup, flags, io_priority, cancellable, callback, user_data) ⇒ nil
-
#replace_readwrite_finish(file, res) ⇒ Gio::FileIOStream
A GFile::IOStream, or nil on error.
-
#resolve_relative_path(file, relative_path) ⇒ Gio::File
A #GFile for the resolved path.
-
#set_attribute(file, attribute, type, value_p, flags, cancellable) ⇒ Boolean
True if the attribute was set, false otherwise.
-
#set_attribute_byte_string(attribute, value, flags, cancellable) ⇒ Boolean
Sets attribute of type %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING to value.
-
#set_attribute_int32(attribute, value, flags, cancellable) ⇒ Boolean
Sets attribute of type %G_FILE_ATTRIBUTE_TYPE_INT32 to value.
-
#set_attribute_int64(attribute, value, flags, cancellable) ⇒ Boolean
Sets attribute of type %G_FILE_ATTRIBUTE_TYPE_INT64 to value.
-
#set_attribute_string(attribute, value, flags, cancellable) ⇒ Boolean
Sets attribute of type %G_FILE_ATTRIBUTE_TYPE_STRING to value.
-
#set_attribute_uint32(attribute, value, flags, cancellable) ⇒ Boolean
Sets attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT32 to value.
-
#set_attribute_uint64(attribute, value, flags, cancellable) ⇒ Boolean
Sets attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT64 to value.
- #set_attributes_async(file, info, flags, io_priority, cancellable, callback, user_data) ⇒ nil
-
#set_attributes_finish(file, result, info) ⇒ Boolean
True if the attributes were set correctly, false otherwise.
-
#set_attributes_from_info(file, info, flags, cancellable) ⇒ Boolean
False if there was any error, true otherwise.
-
#set_display_name(file, display_name, cancellable) ⇒ Gio::File
A #GFile specifying what file was renamed to, or nil if there was an error.
- #set_display_name_async(file, display_name, io_priority, cancellable, callback, user_data) ⇒ nil
-
#set_display_name_finish(file, res) ⇒ Gio::File
A #GFile or nil on error.
- #start_mountable(file, flags, start_operation, cancellable, callback, user_data) ⇒ nil
-
#start_mountable_finish(file, result) ⇒ Boolean
otherwise.
- #stop_mountable(file, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
-
#stop_mountable_finish(file, result) ⇒ Boolean
True if the operation finished successfully.
-
#supports_thread_contexts ⇒ Boolean
Checks if file supports [thread-default contexts][g-main-context-push-thread-default-context].
-
#trash(file, cancellable) ⇒ Boolean
True on successful trash, false otherwise.
- #trash_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
-
#trash_finish(file, result) ⇒ Boolean
True on successful trash, false otherwise.
- #unmount_mountable(file, flags, cancellable, callback, user_data) ⇒ nil
-
#unmount_mountable_finish(file, result) ⇒ Boolean
True if the operation finished successfully.
- #unmount_mountable_with_operation(file, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
-
#unmount_mountable_with_operation_finish(file, result) ⇒ Boolean
True if the operation finished successfully.
-
#uri ⇒ String
Gets the URI for the file.
-
#uri_scheme ⇒ String
Gets the URI scheme for a #GFile.
Class Method Details
.open(options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gio2/file.rb', line 20 def open(={}) arg = [:arg] cwd = [:cwd] path = [:path] uri = [:uri] if arg if cwd file = new_for_commandline_arg_and_cmd(arg, cwd) else file = new_for_commandline_arg(arg) end elsif path path = path.to_path if path.respond_to?(:to_path) file = new_for_path(path) elsif uri file = new_for_uri(uri) else = "must specify :arg, :path or :uri: #{.inspect}" raise ArgumentError, end if block_given? yield(file) else file end end |
Instance Method Details
#_query_settable_attributes_async ⇒ nil
#_query_settable_attributes_finish ⇒ nil
#_query_writable_namespaces_async ⇒ nil
#_query_writable_namespaces_finish ⇒ nil
#append_to(file, flags, cancellable) ⇒ Gio::FileOutputStream
Returns a GFile::OutputStream, or nil on error. Free the returned object with g_object_unref().
#append_to_async(file, flags, io_priority, cancellable, callback, user_data) ⇒ nil
#append_to_finish(file, res) ⇒ Gio::FileOutputStream
Returns a valid GFile::OutputStream or nil on error. Free the returned object with g_object_unref().
#basename ⇒ Gio::filename
Gets the base name (the last component of the path) for a given #GFile.
If called for the top level 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).
The base name is a byte string (not UTF-8). It has no defined encoding or rules other than it may not contain zero bytes. If you want to use filenames in a user interface you should use the display name that you can get by requesting the %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info().
This call does no blocking I/O.
#build_attribute_list_for_copy(flags, cancellable) ⇒ String
Prepares the file attribute query string for copying to file.
This function prepares an attribute query string to be passed to g_file_query_info() to get a list of attributes normally copied with the file (see g_file_copy_attributes() for the detailed description). This function is used by the implementation of g_file_copy_attributes() and is useful when one needs to query and set the attributes in two stages (e.g., for recursive move of a directory).
#copy(source, destination, flags, cancellable, progress_callback, progress_callback_data) ⇒ Boolean
Returns true on success, false otherwise.
#copy_async(source, destination, flags, io_priority, cancellable, progress_callback, progress_callback_data, callback, user_data) ⇒ nil
#copy_attributes(destination, flags, cancellable) ⇒ Boolean
Copies the file attributes from source to destination.
Normally only a subset of the file attributes are copied, those that are copies in a normal file copy operation (which for instance does not include e.g. owner). However if %G_FILE_COPY_ALL_METADATA is specified in flags, then all the metadata that is possible to copy is copied. This is useful when implementing move by copy + delete source.
#copy_finish(file, res) ⇒ Boolean
Returns a true on success, false on error.
#create(file, flags, cancellable) ⇒ Gio::FileOutputStream
Returns a GFile::OutputStream for the newly created file, or nil on error. Free the returned object with g_object_unref().
#create_async(file, flags, io_priority, cancellable, callback, user_data) ⇒ nil
#create_finish(file, res) ⇒ Gio::FileOutputStream
Returns a GFile::OutputStream or nil on error. Free the returned object with g_object_unref().
#create_readwrite(file, flags, cancellable) ⇒ Gio::FileIOStream
Returns a GFile::IOStream for the newly created file, or nil on error. Free the returned object with g_object_unref().
#create_readwrite_async(file, flags, io_priority, cancellable, callback, user_data) ⇒ nil
#create_readwrite_finish(file, res) ⇒ Gio::FileIOStream
Returns a GFile::IOStream or nil on error. Free the returned object with g_object_unref().
#delete(cancellable) ⇒ Boolean
Deletes a file. If the file is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().
If file doesn’t exist, %G_IO_ERROR_NOT_FOUND will be returned. This allows for deletion to be implemented avoiding time-of-check to time-of-use races: |[ g_autoptr(GError) local_error = NULL; if (!g_file_delete (my_file, my_cancellable, &local_error) && !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) { // deletion failed for some reason other than the file not existing: // so report the error g_warning ("Failed to delete %s: %s", g_file_peek_path (my_file), local_error->message); } ]|
If cancellable is not nil, 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.
#delete_async(io_priority, cancellable, callback, user_data) ⇒ nil
Asynchronously delete a file. If the file is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().
#delete_file(file, cancellable) ⇒ Boolean
Returns true if the file was deleted. false otherwise.
#delete_file_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
#delete_file_finish(file, result) ⇒ Boolean
Returns true if the file was deleted. false otherwise.
#delete_finish(result) ⇒ Boolean
Finishes deleting a file started with g_file_delete_async().
#display_name_finish=(res) ⇒ Gio::File
Finishes setting a display name started with g_file_set_display_name_async().
#dup(file) ⇒ Gio::File
Returns a new #GFile that is a duplicate of the given #GFile.
#eject_mountable(file, flags, cancellable, callback, user_data) ⇒ nil
#eject_mountable_finish(file, result) ⇒ Boolean
Returns true if the file was ejected successfully. false otherwise.
#eject_mountable_with_operation(file, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
#eject_mountable_with_operation_finish(file, result) ⇒ Boolean
Returns true if the file was ejected successfully. false otherwise.
#enumerate_children(file, attributes, flags, cancellable) ⇒ Gio::FileEnumerator
Returns A GFile::Enumerator if successful, nil on error. Free the returned object with g_object_unref().
#enumerate_children_async(file, attributes, flags, io_priority, cancellable, callback, user_data) ⇒ nil
#enumerate_children_finish(file, res) ⇒ Gio::FileEnumerator
Returns a GFile::Enumerator or nil if an error occurred. Free the returned object with g_object_unref().
#equal(file1, file2) ⇒ Boolean
Returns true if file1 and file2 are equal.
#find_enclosing_mount(file, cancellable) ⇒ Gio::Mount
Returns a #GMount where the file is located or nil on error. Free the returned object with g_object_unref().
#find_enclosing_mount_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
#find_enclosing_mount_finish(file, res) ⇒ Gio::Mount
Returns #GMount for given file or nil on error. Free the returned object with g_object_unref().
#get_basename(file) ⇒ Gio::filename
Returns string containing the #GFile's base name, or nil if given #GFile is invalid. The returned string should be freed with g_free() when no longer needed.
#get_child(name) ⇒ Gio::File
Gets a child of file with basename equal to name.
Note that the file with that specific name might not exist, but you can still have a #GFile that points to it. You can use this for instance to create that file.
This call does no blocking I/O.
#get_child_for_display_name(file, display_name) ⇒ Gio::File
Returns a #GFile to the specified child, or nil if the display name couldn't be converted. Free the returned object with g_object_unref().
#get_parent(file) ⇒ Gio::File
Returns a #GFile structure to the parent of the given #GFile or nil if there is no parent. Free the returned object with g_object_unref().
#get_parse_name(file) ⇒ String
Returns a string containing the #GFile's parse name. The returned string should be freed with g_free() when no longer needed.
#get_path(file) ⇒ Gio::filename
Returns string containing the #GFile's path, or nil if no such path exists. The returned string should be freed with g_free() when no longer needed.
#get_relative_path(parent, descendant) ⇒ Gio::filename
Returns string with the relative path from descendant to parent, or nil if descendant doesn't have parent as prefix. The returned string should be freed with g_free() when no longer needed.
#get_uri(file) ⇒ String
Returns a string containing the #GFile's URI. If the #GFile was constructed with an invalid URI, an invalid URI is returned. The returned string should be freed with g_free() when no longer needed.
#get_uri_scheme(file) ⇒ String
A string containing the URI scheme for the given #GFile or nil if the #GFile was constructed with an invalid URI. The returned string should be freed with g_free() when no longer needed.
#has_parent(parent) ⇒ Boolean
Checks if file has a parent, and optionally, if it is parent.
If parent is nil then this function returns true if file has any parent at all. If parent is non-nil then true is only returned if file is an immediate child of parent.
#has_prefix(prefix) ⇒ Boolean
Checks whether file has the prefix specified by prefix.
In other words, if the names of initial elements of file's pathname match prefix. Only full pathname elements are matched, so a path like /foo is not considered a prefix of /foobar, only of /foo/bar.
A #GFile is not a prefix of itself. If you want to check for equality, use g_file_equal().
This call does no I/O, as it works purely on names. As such it can sometimes return false even if file is inside a prefix (from a filesystem point of view), because the prefix of file is an alias of prefix.
#has_uri_scheme(file, uri_scheme) ⇒ Boolean
Returns true if #GFile's backend supports the given URI scheme, false if URI scheme is nil, not supported, or #GFile is invalid.
#hash(file) ⇒ Integer
Returns 0 if file is not a valid #GFile, otherwise an integer that can be used as hash value for the #GFile. This function is intended for easily hashing a #GFile to add to a GHash::Table or similar data structure.
#is_native(file) ⇒ Boolean
Returns true if file is native.
#load_bytes(cancellable, etag_out) ⇒ GLib::Bytes
Loads the contents of file and returns it as #GBytes.
If file is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling g_file_load_contents() and g_bytes_new_take().
For resources, etag_out will be set to nil.
The data contained in the resulting #GBytes is always zero-terminated, but this is not included in the #GBytes length. The resulting #GBytes should be freed with g_bytes_unref() when no longer in use.
#load_bytes_async(cancellable, callback, user_data) ⇒ nil
Asynchronously loads the contents of file as #GBytes.
If file is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling g_file_load_contents_async() and g_bytes_new_take().
callback should call g_file_load_bytes_finish() to get the result of this asynchronous operation.
See g_file_load_bytes() for more information.
#load_bytes_finish(result, etag_out) ⇒ GLib::Bytes
Completes an asynchronous request to g_file_load_bytes_async().
For resources, etag_out will be set to nil.
The data contained in the resulting #GBytes is always zero-terminated, but this is not included in the #GBytes length. The resulting #GBytes should be freed with g_bytes_unref() when no longer in use.
See g_file_load_bytes() for more information.
#load_contents(cancellable, contents, length, etag_out) ⇒ Boolean
Loads the content of the file into memory. The data is always zero-terminated, but this is not included in the resultant length. The returned contents should be freed with g_free() when no longer needed.
If cancellable is not nil, 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.
#load_contents_async(cancellable, callback, user_data) ⇒ nil
Starts an asynchronous load of the file's contents.
For more details, see g_file_load_contents() which is the synchronous version of this call.
When the load operation has completed, callback will be called with user data. To finish the operation, call g_file_load_contents_finish() with the GAsync::Result returned by the callback.
If cancellable is not nil, 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.
#load_contents_finish(res, contents, length, etag_out) ⇒ Boolean
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. The contents should be freed with g_free() when no longer needed. If etag_out is present, it will be set to the new entity tag for the file.
#load_partial_contents_async(cancellable, read_more_callback, callback, user_data) ⇒ nil
Reads the partial contents of a file. A GFile::ReadMoreCallback should be used to stop reading from the file when appropriate, else this function will behave exactly as g_file_load_contents_async(). This operation can be finished by g_file_load_partial_contents_finish().
Users of this function should be aware that user_data is passed to both the read_more_callback and the callback.
If cancellable is not nil, 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.
#load_partial_contents_finish(res, contents, length, etag_out) ⇒ Boolean
Finishes an asynchronous partial load operation that was started with g_file_load_partial_contents_async(). The data is always zero-terminated, but this is not included in the resultant length. The returned contents should be freed with g_free() when no longer needed.
#make_directory(file, cancellable) ⇒ Boolean
Returns true on successful creation, false otherwise.
#make_directory_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
#make_directory_finish(file, result) ⇒ Boolean
Returns true on successful directory creation, false otherwise.
#make_directory_with_parents(cancellable) ⇒ Boolean
Creates a directory and any parent directories that may not exist similar to 'mkdir -p'. If the file system does not support creating directories, this function will fail, setting error to %G_IO_ERROR_NOT_SUPPORTED. If the directory itself already exists, this function will fail setting error to %G_IO_ERROR_EXISTS, unlike the similar g_mkdir_with_parents().
For a local #GFile the newly created directories will have the default (current) ownership and permissions of the current process.
If cancellable is not nil, 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. otherwise.
#make_symbolic_link(file, symlink_value, cancellable) ⇒ Boolean
Returns true on the creation of a new symlink, false otherwise.
#make_symbolic_link_async(file, symlink_value, io_priority, cancellable, callback, user_data) ⇒ nil
#make_symbolic_link_finish(file, result) ⇒ Boolean
Returns true on successful directory creation, false otherwise.
#measure_disk_usage(file, flags, cancellable, progress_callback, progress_data, disk_usage, num_dirs, num_files) ⇒ Boolean
Returns true if successful, with the out parameters set. false otherwise, with error set.
#measure_disk_usage_async(file, flags, io_priority, cancellable, progress_callback, progress_data, callback, user_data) ⇒ nil
#measure_disk_usage_finish(file, result, disk_usage, num_dirs, num_files) ⇒ Boolean
Returns true if successful, with the out parameters set. false otherwise, with error set.
#monitor(flags, cancellable) ⇒ Gio::FileMonitor
Obtains a file or directory monitor for the given file, depending on the type of the file.
If cancellable is not nil, 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.
#monitor_dir(file, flags, cancellable) ⇒ Gio::FileMonitor
Returns a GFile::Monitor for the given file, or nil on error. Free the returned object with g_object_unref().
#monitor_directory(flags, cancellable) ⇒ Gio::FileMonitor
Obtains a directory monitor for the given file. This may fail if directory monitoring is not supported.
If cancellable is not nil, 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.
It does not make sense for flags to contain %G_FILE_MONITOR_WATCH_HARD_LINKS, since hard links can not be made to directories. It is not possible to monitor all the files in a directory for changes made via hard links; if you want to do this then you must register individual watches with g_file_monitor().
#monitor_file(file, flags, cancellable) ⇒ Gio::FileMonitor
Returns a GFile::Monitor for the given file, or nil on error. Free the returned object with g_object_unref().
#mount_enclosing_volume(location, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
#mount_enclosing_volume_finish(location, result) ⇒ Boolean
Returns true if successful. If an error has occurred, this function will return false and set error appropriately if present.
#mount_mountable(file, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
#mount_mountable_finish(file, result) ⇒ Gio::File
Returns a #GFile or nil on error. Free the returned object with g_object_unref().
#move(source, destination, flags, cancellable, progress_callback, progress_callback_data) ⇒ Boolean
Returns true on successful move, false otherwise.
#move_async(source, destination, flags, io_priority, cancellable, progress_callback, progress_callback_data, callback, user_data) ⇒ nil
#move_finish(file, result) ⇒ Boolean
Returns true on successful file move, false otherwise.
#open_readwrite(file, cancellable) ⇒ Gio::FileIOStream
Returns GFile::IOStream or nil on error. Free the returned object with g_object_unref().
#open_readwrite_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
#open_readwrite_finish(file, res) ⇒ Gio::FileIOStream
Returns a GFile::IOStream or nil on error. Free the returned object with g_object_unref().
#parent ⇒ Gio::File
Gets the parent directory for the file. If the file represents the root directory of the file system, then nil will be returned.
This call does no blocking I/O.
#parse_name ⇒ String
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 #GFile back using g_file_parse_name().
This is generally used to show the #GFile as a nice full-pathname kind of string in a user interface, like in a location entry.
For local files with names that can safely be converted to UTF-8 the pathname is used, otherwise the IRI is used (a form of URI that allows UTF-8 characters unescaped).
This call does no blocking I/O.
#path ⇒ Gio::filename
Gets the local pathname for #GFile, if one exists. If non-nil, this is guaranteed to be an absolute, canonical path. It might contain symlinks.
This call does no blocking I/O.
#peek_path ⇒ Gio::filename
Exactly like g_file_get_path(), but caches the result via
g_object_set_qdata_full(). This is useful for example in C
applications which mix g_file_* APIs with native ones. It
also avoids an extra duplicated string when possible, so will be
generally more efficient.
This call does no blocking I/O.
#poll_mountable(file, cancellable, callback, user_data) ⇒ nil
#poll_mountable_finish(file, result) ⇒ Boolean
otherwise.
#prefix_matches(prefix, file) ⇒ Boolean
Returns true if the file's parent, grandparent, etc is prefix, false otherwise.
#query_default_handler(cancellable) ⇒ Gio::AppInfo
Returns the GApp::Info that is registered as the default application to handle the file specified by file.
If cancellable is not nil, 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.
#query_default_handler_async(io_priority, cancellable, callback, user_data) ⇒ nil
Async version of g_file_query_default_handler().
#query_default_handler_finish(result) ⇒ Gio::AppInfo
Finishes a g_file_query_default_handler_async() operation.
#query_exists(cancellable) ⇒ Boolean
Utility function to check if a particular file exists. This is implemented using g_file_query_info() and as such does blocking I/O.
Note that in many cases it is racy to first check for file existence and then execute something based on the outcome of that, because the file might have been created or removed in between the operations. The general approach to handling that is to not check, but just do the operation and handle the errors as they come.
As an example of race-free checking, take the case of reading a file, and if it doesn't exist, creating it. There are two racy versions: read it, and on error create it; and: check if it exists, if not create it. These can both result in two processes creating the file (with perhaps a partially written file as the result). The correct approach is to always try to create the file with g_file_create() which will either atomically create the file or fail with a %G_IO_ERROR_EXISTS error.
However, in many cases an existence check is useful in a user interface, for instance to make a menu item sensitive/insensitive, so that you don't have to fool users that something is possible and then just show an error dialog. If you do this, you should make sure to also handle the errors that can happen due to races when you execute the operation.
#query_file_type(flags, cancellable) ⇒ Gio::FileType
Utility function to inspect the GFile::Type of a file. This is implemented using g_file_query_info() and as such does blocking I/O.
The primary use case of this method is to check if a file is a regular file, directory, or symlink.
#query_filesystem_info(file, attributes, cancellable) ⇒ Gio::FileInfo
Returns a GFile::Info or nil if there was an error. Free the returned object with g_object_unref().
#query_filesystem_info_async(file, attributes, io_priority, cancellable, callback, user_data) ⇒ nil
#query_filesystem_info_finish(file, res) ⇒ Gio::FileInfo
Returns GFile::Info for given file or nil on error. Free the returned object with g_object_unref().
#query_info(file, attributes, flags, cancellable) ⇒ Gio::FileInfo
Returns a GFile::Info for the given file, or nil on error. Free the returned object with g_object_unref().
#query_info_async(file, attributes, flags, io_priority, cancellable, callback, user_data) ⇒ nil
#query_info_finish(file, res) ⇒ Gio::FileInfo
Returns GFile::Info for given file or nil on error. Free the returned object with g_object_unref().
#query_settable_attributes(file, cancellable) ⇒ Gio::FileAttributeInfoList
Returns a GFile::AttributeInfoList describing the settable attributes. When you are done with it, release it with g_file_attribute_info_list_unref().
#query_writable_namespaces(file, cancellable) ⇒ Gio::FileAttributeInfoList
Returns a GFile::AttributeInfoList describing the writable namespaces. When you are done with it, release it with g_file_attribute_info_list_unref().
#read(cancellable = nil) ⇒ Gio::FileInputStream
Opens a file for reading. The result is a GFile::InputStream that can be used to read the contents of the file.
If cancellable is not nil, 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.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gio2/file.rb', line 51 def read(cancellable=nil) input_stream = read_raw(cancellable) return input_stream unless block_given? begin yield(input_stream) ensure input_stream.close unless input_stream.closed? end end |
#read_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
#read_finish(file, res) ⇒ Gio::FileInputStream
Returns a GFile::InputStream or nil on error. Free the returned object with g_object_unref().
#read_fn(file, cancellable) ⇒ Gio::FileInputStream
Returns GFile::InputStream or nil on error. Free the returned object with g_object_unref().
#read_raw ⇒ Gio::FileInputStream
Opens a file for reading. The result is a GFile::InputStream that can be used to read the contents of the file.
If cancellable is not nil, 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.
|
|
# File 'lib/gio2/file.rb', line 50
|
#replace(file, etag, make_backup, flags, cancellable) ⇒ Gio::FileOutputStream
Returns a GFile::OutputStream or nil on error. Free the returned object with g_object_unref().
#replace_async(file, etag, make_backup, flags, io_priority, cancellable, callback, user_data) ⇒ nil
#replace_contents(contents, length, etag, make_backup, flags, new_etag, cancellable) ⇒ Boolean
Replaces the contents of file with contents of length bytes.
If etag is specified (not nil), 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. Internally, it uses g_file_replace(), so will try to replace the file contents in the safest way possible. For example, atomic renames are used when replacing local files’ contents.
If cancellable is not nil, 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.
#replace_contents_async(contents, length, etag, make_backup, flags, cancellable, callback, user_data) ⇒ nil
Starts an asynchronous replacement of file with the given contents of length bytes. etag will replace the document's current entity tag.
When this operation has completed, callback will be called with user_user data, and the operation can be finalized with g_file_replace_contents_finish().
If cancellable is not nil, 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 make_backup is true, this function will attempt to make a backup of file.
Note that no copy of contents will be made, so it must stay valid until callback is called. See g_file_replace_contents_bytes_async() for a #GBytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.
#replace_contents_bytes_async(contents, etag, make_backup, flags, cancellable, callback, user_data) ⇒ nil
Same as g_file_replace_contents_async() but takes a #GBytes input instead. This function will keep a ref on contents until the operation is done. Unlike g_file_replace_contents_async() this allows forgetting about the content without waiting for the callback.
When this operation has completed, callback will be called with user_user data, and the operation can be finalized with g_file_replace_contents_finish().
#replace_contents_finish(res, new_etag) ⇒ Boolean
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.
#replace_finish(file, res) ⇒ Gio::FileOutputStream
Returns a GFile::OutputStream, or nil on error. Free the returned object with g_object_unref().
#replace_readwrite(file, etag, make_backup, flags, cancellable) ⇒ Gio::FileIOStream
Returns a GFile::IOStream or nil on error. Free the returned object with g_object_unref().
#replace_readwrite_async(file, etag, make_backup, flags, io_priority, cancellable, callback, user_data) ⇒ nil
#replace_readwrite_finish(file, res) ⇒ Gio::FileIOStream
Returns a GFile::IOStream, or nil on error. Free the returned object with g_object_unref().
#resolve_relative_path(file, relative_path) ⇒ Gio::File
Returns a #GFile for the resolved path.
#set_attribute(file, attribute, type, value_p, flags, cancellable) ⇒ Boolean
Returns true if the attribute was set, false otherwise.
#set_attribute_byte_string(attribute, value, flags, cancellable) ⇒ Boolean
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 nil, 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.
#set_attribute_int32(attribute, value, flags, cancellable) ⇒ Boolean
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 nil, 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.
#set_attribute_int64(attribute, value, flags, cancellable) ⇒ Boolean
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 nil, 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.
#set_attribute_string(attribute, value, flags, cancellable) ⇒ Boolean
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 nil, 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.
#set_attribute_uint32(attribute, value, flags, cancellable) ⇒ Boolean
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 nil, 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.
#set_attribute_uint64(attribute, value, flags, cancellable) ⇒ Boolean
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 nil, 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.
#set_attributes_async(file, info, flags, io_priority, cancellable, callback, user_data) ⇒ nil
#set_attributes_finish(file, result, info) ⇒ Boolean
Returns true if the attributes were set correctly, false otherwise.
#set_attributes_from_info(file, info, flags, cancellable) ⇒ Boolean
Returns false if there was any error, true otherwise.
#set_display_name(file, display_name, cancellable) ⇒ Gio::File
Returns a #GFile specifying what file was renamed to, or nil if there was an error. Free the returned object with g_object_unref().
#set_display_name_async(file, display_name, io_priority, cancellable, callback, user_data) ⇒ nil
#set_display_name_finish(file, res) ⇒ Gio::File
Returns a #GFile or nil on error. Free the returned object with g_object_unref().
#start_mountable(file, flags, start_operation, cancellable, callback, user_data) ⇒ nil
#start_mountable_finish(file, result) ⇒ Boolean
otherwise.
#stop_mountable(file, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
#stop_mountable_finish(file, result) ⇒ Boolean
Returns true if the operation finished successfully. false otherwise.
#supports_thread_contexts ⇒ Boolean
Checks if file supports [thread-default contexts][g-main-context-push-thread-default-context]. If this returns false, you cannot perform asynchronous operations on file in a thread that has a thread-default context.
#trash(file, cancellable) ⇒ Boolean
Returns true on successful trash, false otherwise.
#trash_async(file, io_priority, cancellable, callback, user_data) ⇒ nil
#trash_finish(file, result) ⇒ Boolean
Returns true on successful trash, false otherwise.
#unmount_mountable(file, flags, cancellable, callback, user_data) ⇒ nil
#unmount_mountable_finish(file, result) ⇒ Boolean
Returns true if the operation finished successfully. false otherwise.
#unmount_mountable_with_operation(file, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
#unmount_mountable_with_operation_finish(file, result) ⇒ Boolean
Returns true if the operation finished successfully. false otherwise.
#uri ⇒ String
Gets the URI for the file.
This call does no blocking I/O.
#uri_scheme ⇒ String
Gets the URI scheme for a #GFile. RFC 3986 decodes the scheme as: |[ URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] ]| Common schemes include "file", "http", "ftp", etc.
The scheme can be different from the one used to construct the #GFile, in that it might be replaced with one that is logically equivalent to the #GFile.
This call does no blocking I/O.