Back to Seed Clases

Gio


Classes

Interfaces

Structs

Unions

Enums

Interface Gio.File

Import line: Gio = imports.gi.Gio;
GIR File: Gio-2.0.gir
C documentation: GFile
Interface : File
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 GInputStream and
GOutputStream).
g_file_new_for_path() if you have a path.
g_file_new_for_uri() if you have a URI.
g_file_new_for_commandline_arg() for a command line argument.
g_file_parse_name() from a utf8 string gotten from g_file_get_parse_name().
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
g_file_get_parent() to get an identifier for the parent directory, g_file_get_child()
to get a child within a directory, g_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 g_file_get_parent() on two different
files.
All GFiles have a basename (get with g_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 g_file_query_info().
This is guaranteed to be in utf8 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.
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 GAsyncReadyCallback which is then used to finalize
the operation, producing a GAsyncResult which is then passed to the
function's matching _finish() operation.
Some GFile 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:
g_file_mount_mountable() to mount a mountable file.
g_file_unmount_mountable_with_operation() to unmount a mountable file.
g_file_eject_mountable_with_operation() to eject a mountable file.
entity tag
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.

To construct a gfile, you can use:
Properties
None
Methods / Constructors
Method / Constructor Defined By
Events
None
Used by These Methods / Signals / Properties
Class / Namespace Method / Signal / Properties
EvinceDocument
Method
EvinceDocument.file_is_temp (File file) : gboolean
EvinceDocument
Method
EvinceDocument.tmp_file_unlink (File file) : none
EvinceDocument.Attachment
Method
save (File file) : gboolean
Gio
Method
Gio.content_type_guess_for_tree (File root) : Array
Tries to guess the type of the tree with root root, by
looking at the files it contains.
Gio
Method
Gio.file_new_for_commandline_arg (String arg) : Gio.File
Creates a GFile with the given argument from the command line.
Gio
Method
Gio.file_new_for_path (String path) : Gio.File
Constructs a GFile for a given path.
Gio
Method
Gio.file_new_for_uri (String uri) : Gio.File
Constructs a GFile for a given URI.
Gio
Method
Gio.file_parse_name (String parse_name) : Gio.File
Constructs a GFile with the given parse_name (i.e.
Gio.FileEnumerator
Property
container : Gio.File
Gio.FileEnumerator
Method
get_container () : Gio.File
Get the GFile container which is being enumerated.
Gio.FileIcon
Property
file : Gio.File
The file containing the icon.
Gio.FileIcon
Method
get_file () : Gio.File
Gets the GFile associated with the given icon.
Gio.FileMonitor
Signal
changed (FileMonitor self, File file, File other_file, FileMonitorEvent event_type) : none
Emitted when file has been changed.
Gio.FileMonitor
Method
emit_event (File child, File other_file, FileMonitorEvent event_type) : none
Emits the GFileMonitor::changed signal if a change
has taken place.
Gio.Mount
Method
get_default_location () : Gio.File
Gets the default location of mount.
Gio.Mount
Method
get_root () : Gio.File
Gets the root directory on mount.
Gio.Vfs
Method
get_file_for_path (String path) : Gio.File
Gets a GFile for path.
Gio.Vfs
Method
get_file_for_uri (String uri) : Gio.File
Gets a GFile for uri.
Gio.Vfs
Method
parse_name (String parse_name) : Gio.File
This operation never fails, but the returned object might
not support any I/O operations if the parse_name cannot
be parsed by the GVfs module.
Gio.Volume
Method
get_activation_root () : Gio.File
Gets the activation root for a GVolume if it is known ahead of
mount time.
Gtk.AppChooserDialog
Property
gfile : Gio.File
The GFile used by the GtkAppChooserDialog.
Gtk.AppChooserDialog
Method
new Gtk.AppChooserDialog.c_new (Window parent, DialogFlags flags, File file) : Gtk.Widget
Create a new Gtk.AppChooserDialog
Gtk.CssProvider
Method
load_from_file (File file) : gboolean
Loads the data contained in file into css_provider, making it
clear any previously loaded information.
Gtk.FileChooser
Method
get_current_folder_file () : Gio.File
Gets the current folder of chooser as GFile.
Gtk.FileChooser
Method
get_file () : Gio.File
Gets the GFile for the currently selected file in
the file selector.
Gtk.FileChooser
Method
get_preview_file () : Gio.File
Gets the GFile that should be previewed in a custom preview
Internal function, see gtk_file_chooser_get_preview_uri().
Gtk.FileChooser
Method
select_file (File file) : gboolean
Selects the file referred to by file.
Gtk.FileChooser
Method
set_current_folder_file (File file) : gboolean
Sets the current folder for chooser from a GFile.
Gtk.FileChooser
Method
set_file (File file) : gboolean
Sets file as the current filename for the file chooser, by changing
to the file's parent folder and actually selecting the file in list.
Gtk.FileChooser
Method
unselect_file (File file) : none
Unselects the file referred to by file.
TelepathyGLib.Contact
Property
avatar_file : Gio.File read only
TelepathyGLib.Contact
Method
get_avatar_file () : Gio.File
Documentation generated by Introspection Doc Generator Loosely Based on JsDoc Toolkit on Sat Apr 16 2011 17:11:21 GMT+0800 (HKT)