
Gnome::Gio::File
File and Directory Handling
Description
Gnome::Gio::File is a high level abstraction for manipulating files on a virtual file system. N-GFiles are lightweight, immutable objects that do no I/O upon creation. It is necessary to understand that Gnome::Gio::File objects do not represent files, merely an identifier for a file.
To construct a Gnome::Gio::File, you can use:
.new(:path)
if you have a path..new(:uri)
if you have a URI..new(:commandline-arg)
for a command line argument.
One way to think of a Gnome::Gio::File is as an abstraction of a pathname. For normal files the system pathname is what is stored internally, but as N-GFiles are extensible it could also be something else that corresponds to a pathname in a userspace implementation of a filesystem.
Many of the native subroutines originally in this module are not implemented in this Raku class. This is because I/O is very well supported by Raku and there is no need to provide I/O routines here. This class mainly exists to handle returned native objects from other classes. The most important calls needed are thus to get the name of a file or url.
Synopsis
Declaration
unit class Gnome::Gio::File; also is Gnome::N::TopLevelClassSupport;
Note
Gnome::Gio::File is defined as an interface in the Gnome libraries and therefore should be defined as a Raku role. However, many Gnome modules return native Gnome::Gio::File objects as if they are class objects. There aren't even Gnome classes using it as an interface. Presumably, it is defined like that so the developer can create classes using the File class as an interface which will not be the case in Raku.
Note
Gnome::Gio::File has many functions of which a large part will not be made available in Raku. This is because many are about read/write, move and rename which Raku is able to do very nice.
Types
class N-GFile
Native object to hold a file representation
Methods
new
:path
Create a new File object using a path to a file.
multi method new ( Str :$path! )
:uri
Create a new File object using a uri.
multi method new ( Str :$uri! )
:commandline-arg, :cwd
Creates a Gnome::Gio::File with the 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.
Note that on Windows, this function expects its argument to be in UTF-8 -- not the system code page. This means that you should not use this function with string from argv as it is passed to main()
. g-win32-get-command-line()
will return a UTF-8 version of the commandline. Gnome::Gio::Application also uses UTF-8 but g-application-command-line-create-file-for-arg()
may be more useful for you there. It is also always possible to use this function with Gnome::Gio::OptionContext arguments of type G-OPTION-ARG-FILENAME
.
Optionally a directory relative to the argument can be given in $cwd. Otherwise the working directory of the application is used.
multi method new ( Str :$commandline-arg!, Str :$cwd? )
:native-object
Create a File object using a native object from elsewhere. See also Gnome::N::TopLevelClassSupport.
multi method new ( N-GObject :$native-object! )
[g_] object_unref
Decreases the reference count of the native object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).
method g_object_unref ( N-GFile $object )
$object; a N-GFile
append-to
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 Gnome::Gio::-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 undefined
, 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 file systems don't allow all file names, 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.
Returns: a Gnome::Gio::FileOutputStream, or undefined
on error. Free the returned object with clear-object()
.
method append-to ( UInt $flags, GCancellable $cancellable, N-GError $error --> GFileOutputStream )
$flags; a set of UInt
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
append-to-async
Asynchronously opens file for appending.
For more details, see append-to()
which is the synchronous version of this call.
When the operation is finished, callback will be called. You can then call g-file-append-to-finish()
to get the result of the operation.
method append-to-async ( UInt $flags, Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$flags; a set of Gnome::Gio::FileCreateFlags
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
append-to-finish
Finishes an asynchronous file append operation started with append-to-async()
.
Returns: a valid Gnome::Gio::FileOutputStream or undefined
on error. Free the returned object with clear-object()
.
method append-to-finish ( GAsyncResult $res, N-GError $error --> GFileOutputStream )
$res; Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
copy
Copies the file source to the location specified by destination. Can not handle recursive copies of directories.
If the flag Gnome::Gio::-FILE-COPY-OVERWRITE is specified an already existing destination file is overwritten.
If the flag Gnome::Gio::-FILE-COPY-NOFOLLOW-SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.
If the flag Gnome::Gio::-FILE-COPY-ALL-METADATA is specified then all the metadata that is possible to copy is copied, not just the default subset (which, for instance, does not include the owner, see Gnome::Gio::FileInfo).
If cancellable is not undefined
, 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 progress-callback is not undefined
, then the operation can be monitored by setting this to a Gnome::Gio::FileProgressCallback function. progress-callback-data will be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation.
If the source file does not exist, then the G-IO-ERROR-NOT-FOUND
error is returned, independent on the status of the destination.
If Gnome::Gio::-FILE-COPY-OVERWRITE is not specified and the target exists, then the error G-IO-ERROR-EXISTS
is returned.
If trying to overwrite a file over a directory, the G-IO-ERROR-IS-DIRECTORY
error is returned. If trying to overwrite a directory with a directory the G-IO-ERROR-WOULD-MERGE
error is returned.
If the source is a directory and the target does not exist, or Gnome::Gio::-FILE-COPY-OVERWRITE is specified and the target is a file, then the G-IO-ERROR-WOULD-RECURSE
error is returned.
If you are interested in copying the Gnome::Gio::File object itself (not the on-disk file), see dup()
.
Returns: True
on success, False
otherwise.
method copy ( N-GFile $destination, UInt $flags, GCancellable $cancellable, GFileProgressCallback $progress_callback, Pointer $progress_callback_data, N-GError $error --> Bool )
$destination; destination Gnome::Gio::File
$flags; set of Gnome::Gio::FileCopyFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$progress_callback; (scope call): function to callback with progress information, or
undefined
if progress information is not needed$progress_callback_data; (closure): user data to pass to progress-callback
$error; Gnome::Gio::Error to set on error, or
undefined
copy-async
Copies the file source to the location specified by destination asynchronously. For details of the behaviour, see copy()
.
If progress-callback is not undefined
, then that function that will be called just like in g-file-copy()
. The callback will run in the default main context of the thread calling g-file-copy-async()
— the same context as callback is run in.
When the operation is finished, callback will be called. You can then call g-file-copy-finish()
to get the result of the operation.
method copy-async ( N-GFile $destination, UInt $flags, Int() $io_priority, GCancellable $cancellable, GFileProgressCallback $progress_callback, Pointer $progress_callback_data, GAsyncReadyCallback $callback, Pointer $user_data )
$destination; destination Gnome::Gio::File
$flags; set of Gnome::Gio::FileCopyFlags
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$progress_callback; (scope notified): function to callback with progress information, or
undefined
if progress information is not needed$progress_callback_data; (closure progress-callback) : user data to pass to progress-callback
$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure callback): the data to pass to callback function
copy-attributes
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 Gnome::Gio::-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.
Returns: True
if the attributes were copied successfully, False
otherwise.
method copy-attributes ( N-GFile $destination, UInt $flags, GCancellable $cancellable, N-GError $error --> Bool )
$destination; a Gnome::Gio::File to copy attributes to
$flags; a set of Gnome::Gio::FileCopyFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error,
undefined
to ignore
copy-finish
Finishes copying the file started with copy-async()
.
Returns: a True
on success, False
on error.
method copy-finish ( GAsyncResult $res, N-GError $error --> Bool )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
create
Creates a new file and returns an output stream for writing to it. The file must not already exist.
By default files created are generally readable by everyone, but if you pass Gnome::Gio::-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 undefined
, 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 or directory with this name already exists the G-IO-ERROR-EXISTS
error will be returned. Some file systems don't allow all file names, 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.
Returns: a Gnome::Gio::FileOutputStream for the newly created file, or undefined
on error. Free the returned object with clear-object()
.
method create ( UInt $flags, GCancellable $cancellable, N-GError $error --> GFileOutputStream )
$flags; a set of Gnome::Gio::FileCreateFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
create-async
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, callback will be called. You can then call g-file-create-finish()
to get the result of the operation.
method create-async ( UInt $flags, Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$flags; a set of Gnome::Gio::FileCreateFlags
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
create-finish
Finishes an asynchronous file create operation started with create-async()
.
Returns: a Gnome::Gio::FileOutputStream or undefined
on error. Free the returned object with clear-object()
.
method create-finish ( GAsyncResult $res, N-GError $error --> GFileOutputStream )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
create-readwrite
Creates a new file and returns a stream for reading and writing to it. The file must not already exist.
By default files created are generally readable by everyone, but if you pass Gnome::Gio::-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 undefined
, 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 or directory with this name already exists, the G-IO-ERROR-EXISTS
error will be returned. Some file systems don't allow all file names, and may return an G-IO-ERROR-INVALID-FILENAME
error, and if the name is too 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.
Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
Returns: a Gnome::Gio::FileIOStream for the newly created file, or undefined
on error. Free the returned object with clear-object()
.
method create-readwrite ( UInt $flags, GCancellable $cancellable, N-GError $error --> GFileIOStream )
$flags; a set of Gnome::Gio::FileCreateFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; return location for a Gnome::Gio::Error, or
undefined
create-readwrite-async
Asynchronously creates a new file and returns a stream for reading and writing to it. The file must not already exist.
For more details, see create-readwrite()
which is the synchronous version of this call.
When the operation is finished, callback will be called. You can then call g-file-create-readwrite-finish()
to get the result of the operation.
method create-readwrite-async ( UInt $flags, Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$flags; a set of Gnome::Gio::FileCreateFlags
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
create-readwrite-finish
Finishes an asynchronous file create operation started with create-readwrite-async()
.
Returns: a Gnome::Gio::FileIOStream or undefined
on error. Free the returned object with clear-object()
.
method create-readwrite-finish ( GAsyncResult $res, N-GError $error --> GFileIOStream )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
delete
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 cancellable is not undefined
, 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.
Virtual: delete-file
Returns: True
if the file was deleted. False
otherwise.
method delete ( GCancellable $cancellable, N-GError $error --> Bool )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
delete-async
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()
.
Virtual: delete-file-async
method delete-async ( Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; the data to pass to callback function
delete-finish
Finishes deleting a file started with delete-async()
.
Virtual: delete-file-finish
Returns: True
if the file was deleted. False
otherwise.
method delete-finish ( GAsyncResult $result, N-GError $error --> Bool )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
dup
Duplicates a Gnome::Gio::File handle. This operation does not duplicate the actual file or directory represented by the Gnome::Gio::File; see copy()
if attempting to copy a file.
g-file-dup()
is useful when a second handle is needed to the same underlying file, for use in a separate thread (Gnome::Gio::File is not thread-safe). For use within the same thread, use g-object-ref()
to increment the existing object’s reference count.
This call does no blocking I/O.
Returns: a new Gnome::Gio::File that is a duplicate of the given Gnome::Gio::File.
method dup ( --> N-GFile )
eject-mountable-with-operation
Starts an asynchronous eject on a mountable. When this operation has completed, callback will be called with user-user data, and the operation can be finalized with eject-mountable-with-operation-finish()
.
If cancellable is not undefined
, 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.
method eject-mountable-with-operation ( GMountUnmountFlags $flags, GMountOperation $mount_operation, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$flags; flags affecting the operation
$mount_operation; a Gnome::Gio::MountOperation, or
undefined
to avoid user interaction$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async) : a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied, or
undefined
$user_data; (closure): the data to pass to callback function
eject-mountable-with-operation-finish
Finishes an asynchronous eject operation started by eject-mountable-with-operation()
.
Returns: True
if the file was ejected successfully. False
otherwise.
method eject-mountable-with-operation-finish ( GAsyncResult $result, N-GError $error --> Bool )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
enumerate-children
Gets the requested information about the files in a directory. The result is a Gnome::Gio::FileEnumerator object that will give out Gnome::Gio::FileInfo objects for all the files in the directory.
The attributes value is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. attributes should be a comma-separated list of attributes 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 available as defines, like Gnome::Gio::-FILE-ATTRIBUTE-STANDARD-NAME.
If cancellable is not undefined
, 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-IO-ERROR-NOT-DIRECTORY
error will be returned. Other errors are possible too.
Returns: A Gnome::Gio::FileEnumerator if successful, undefined
on error. Free the returned object with clear-object()
.
method enumerate-children ( Str $attributes, GFileQueryInfoFlags $flags, GCancellable $cancellable, N-GError $error --> GFileEnumerator )
$attributes; an attribute query string
$flags; a set of Gnome::Gio::FileQueryInfoFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; Gnome::Gio::Error for error reporting
enumerate-children-async
Asynchronously gets the requested information about the files in a directory. The result is a Gnome::Gio::FileEnumerator object that will give out Gnome::Gio::FileInfo 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, callback will be called. You can then call g-file-enumerate-children-finish()
to get the result of the operation.
method enumerate-children-async ( Str $attributes, GFileQueryInfoFlags $flags, Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$attributes; an attribute query string
$flags; a set of Gnome::Gio::FileQueryInfoFlags
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
enumerate-children-finish
Finishes an async enumerate children operation. See enumerate-children-async()
.
Returns: a Gnome::Gio::FileEnumerator or undefined
if an error occurred. Free the returned object with clear-object()
.
method enumerate-children-finish ( GAsyncResult $res, N-GError $error --> GFileEnumerator )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error
equal
Checks if the two given Gnome::Gio::Files refer to the same file.
Note that two Gnome::Gio::Files that differ can still refer to the same file on the filesystem due to various forms of filename aliasing.
This call does no blocking I/O.
Returns: True
if file1 and file2 are equal.
method equal ( N-GFile $file2 --> Bool )
$file2; the second Gnome::Gio::File
find-enclosing-mount
Gets a Gnome::Gio::Mount for the Gnome::Gio::File.
If the Gnome::Gio::FileIface for file does not have a mount (e.g. possibly a remote share), error will be set to G-IO-ERROR-NOT-FOUND
and undefined
will be returned.
If cancellable is not undefined
, 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.
Returns: a Gnome::Gio::Mount where the file is located or undefined
on error. Free the returned object with clear-object()
.
method find-enclosing-mount ( GCancellable $cancellable, N-GError $error --> GMount )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error
find-enclosing-mount-async
Asynchronously gets the mount for the file.
For more details, see find-enclosing-mount()
which is the synchronous version of this call.
When the operation is finished, callback will be called. You can then call g-file-find-enclosing-mount-finish()
to get the result of the operation.
method find-enclosing-mount-async ( Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
find-enclosing-mount-finish
Finishes an asynchronous find mount request. See find-enclosing-mount-async()
.
Returns: Gnome::Gio::Mount for given file or undefined
on error. Free the returned object with clear-object()
.
method find-enclosing-mount-finish ( GAsyncResult $res, N-GError $error --> GMount )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error
get-basename
Gets the base name (the last component of the path) for a given Gnome::Gio::File.
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 query-info()
.
This call does no blocking I/O.
Returns: (type filename) : string containing the Gnome::Gio::File's base name, or undefined
if given Gnome::Gio::File is invalid. The returned string should be freed with g-free()
when no longer needed.
method get-basename ( --> Str )
get-child
Gets a child of this File with basename equal to name.
Note that the file with that specific name might not exist, but you can still have a Gnome::Gio::File that points to it. You can use this for instance to create that file.
This call does no blocking I/O.
Returns: a Gnome::Gio::File to a child specified by name. Free the returned object with .clear-object()
.
method get-child ( Str $name --> N-GFile )
$name; (type filename): string containing the child's basename
get-child-for-display-name
Gets the child for a given display-name (i.e. a UTF-8 version of the name). If this function fails, it returns undefined
and error will be set. This is very useful when constructing a Gnome::Gio::File 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.
Returns: a native File object to the specified child, or undefined
if the display name couldn't be converted.
When an error takes place, the error object is set and the returned object is invalid. The error is stored in the attribute $.last-error
. Free the returned object with clear-object()
.
method get-child-for-display-name ( Str $display-name --> N-GFile )
Example
my Gnome::Gio::File $f .= new(:path<t/data/g-resources>); my Gnome::Gio::File() $f2 = $f.get-child-for-display-name('rtest') die $f.last-error.message unless $f2.is-valid;
$display_name; string to a possible child
get-parent
Gets the parent directory for the file. If the file represents the root directory of the file system, then undefined
will be returned.
This call does no blocking I/O.
Returns: a Gnome::Gio::File structure to the parent of the given Gnome::Gio::File or undefined
if there is no parent. Free the returned object with clear-object()
.
method get-parent ( --> N-GFile )
get-parse-name
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 Gnome::Gio::File back using parse-name()
.
This is generally used to show the Gnome::Gio::File 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.
Returns: a string containing the Gnome::Gio::File's parse name.
method get-parse-name ( --> Str )
get-path
Gets the local pathname for Gnome::Gio::File, if one exists. If non-undefined
, this is guaranteed to be an absolute, canonical path. It might contain symlinks.
This call does no blocking I/O.
Returns: (type filename) : string containing the Gnome::Gio::File's path, or undefined
if no such path exists. The returned string should be freed with g-free()
when no longer needed.
method get-path ( --> Str )
get-relative-path
Gets the path for descendant relative to parent.
This call does no blocking I/O.
Returns: string with the relative path from descendant to parent, or undefined
if descendant doesn't have parent as prefix.
method get-relative-path ( N-GFile $descendant --> Str )
$descendant; input Gnome::Gio::File
get-uri
Gets the URI for the file.
This call does no blocking I/O.
Returns: a string containing the Gnome::Gio::File's URI. The returned string should be freed with g-free()
when no longer needed.
method get-uri ( --> Str )
get-uri-scheme
Gets the URI scheme for a Gnome::Gio::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 Gnome::Gio::File. The returned string should be freed with g-free()
when no longer needed.
method get-uri-scheme ( --> Str )
has-parent
Checks if file has a parent, and optionally, if it is parent.
If parent is undefined
then this function returns True
if file has any parent at all. If parent is non-undefined
then True
is only returned if file is an immediate child of parent.
Returns: True
if file is an immediate child of parent (or any parent in the case that parent is undefined
).
method has-parent ( N-GFile $parent --> Bool )
$parent; the parent to check for, or
undefined
has-prefix
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 Gnome::Gio::File is not a prefix of itself. If you want to check for equality, use 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.
Virtual: prefix-matches
Returns: True
if the files's parent, grandparent, etc is prefix, False
otherwise.
method has-prefix ( N-GFile $prefix --> Bool )
$prefix; input Gnome::Gio::File
has-uri-scheme
Checks to see if a Gnome::Gio::File has a given URI scheme.
This call does no blocking I/O.
Returns: True
if Gnome::Gio::File's backend supports the given URI scheme, False
if URI scheme is undefined
, not supported, or Gnome::Gio::File is invalid.
method has-uri-scheme ( Str $uri_scheme --> Bool )
$uri_scheme; a string containing a URI scheme
hash
Creates a hash value for a Gnome::Gio::File.
This call does no blocking I/O.
Virtual: hash
Returns: 0 if file is not a valid Gnome::Gio::File, otherwise an integer that can be used as hash value for the Gnome::Gio::File. This function is intended for easily hashing a Gnome::Gio::File to add to a Gnome::Gio::HashTable or similar data structure.
method hash ( Pointer $file --> UInt )
$file; (type N-GFile): gconstpointer to a Gnome::Gio::File
is-native
Checks to see if a file is native to the platform.
A native file is 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 available using the native filesystem via a userspace filesystem (FUSE), in these cases this call will return False
, but get-path()
will still return a native path.
This call does no blocking I/O.
Returns: True
if file is native
method is-native ( --> Bool )
load-bytes
Loads the contents of file and returns it as Gnome::Gio::Bytes.
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 load-contents()
and g-bytes-new-take()
.
For resources, etag-out will be set to undefined
.
The data contained in the resulting Gnome::Gio::Bytes is always zero-terminated, but this is not included in the Gnome::Gio::Bytes length. The resulting Gnome::Gio::Bytes should be freed with g-bytes-unref()
when no longer in use.
Returns: a Gnome::Gio::Bytes or undefined
and error is set
method load-bytes ( GCancellable $cancellable, CArray[Str] $etag_out, N-GError $error --> N-GObject )
$cancellable; a Gnome::Gio::Cancellable or
undefined
$etag_out; a location to place the current entity tag for the file, or
undefined
if the entity tag is not needed$error; a location for a Gnome::Gio::Error or
undefined
load-bytes-async
Asynchronously loads the contents of file as Gnome::Gio::Bytes.
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 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.
method load-bytes-async ( GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$cancellable; a Gnome::Gio::Cancellable or
undefined
$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
load-bytes-finish
Completes an asynchronous request to load-bytes-async()
.
For resources, etag-out will be set to undefined
.
The data contained in the resulting Gnome::Gio::Bytes is always zero-terminated, but this is not included in the Gnome::Gio::Bytes length. The resulting Gnome::Gio::Bytes should be freed with g-bytes-unref()
when no longer in use.
See g-file-load-bytes()
for more information.
Returns: a Gnome::Gio::Bytes or undefined
and error is set
method load-bytes-finish ( GAsyncResult $result, CArray[Str] $etag_out, N-GError $error --> N-GObject )
$result; a Gnome::Gio::AsyncResult provided to the callback
$etag_out; a location to place the current entity tag for the file, or
undefined
if the entity tag is not needed$error; a location for a Gnome::Gio::Error, or
undefined
load-contents
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 content should be freed with g-free()
when no longer needed.
If cancellable is not undefined
, 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.
Returns: True
if the file's contents were successfully loaded. False
if there were errors.
method load-contents ( GCancellable $cancellable, CArray[Str] $contents, UInt $length, CArray[Str] $etag_out, N-GError $error --> Bool )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$contents; (element-type guint8) (array length=length): a location to place the contents of the file
$length; a location to place the length of the contents of the file, or
undefined
if the length is not needed$etag_out; a location to place the current entity tag for the file, or
undefined
if the entity tag is not needed$error; a Gnome::Gio::Error, or
undefined
load-contents-async
Starts an asynchronous load of the file's contents.
For more details, see 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 Gnome::Gio::AsyncResult returned by the callback.
If cancellable is not undefined
, 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.
method load-contents-async ( GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; the data to pass to callback function
load-contents-finish
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 content 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.
Returns: True
if the load was successful. If False
and error is present, it will be set appropriately.
method load-contents-finish ( GAsyncResult $res, CArray[Str] $contents, UInt $length, CArray[Str] $etag_out, N-GError $error --> Bool )
$res; a Gnome::Gio::AsyncResult
$contents; (element-type guint8) (array length=length): a location to place the contents of the file
$length; a location to place the length of the contents of the file, or
undefined
if the length is not needed$etag_out; a location to place the current entity tag for the file, or
undefined
if the entity tag is not needed$error; a Gnome::Gio::Error, or
undefined
load-partial-contents-async
Reads the partial contents of a file. A Gnome::Gio::FileReadMoreCallback should be used to stop reading from the file when appropriate, else this function will behave exactly as 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 undefined
, 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.
method load-partial-contents-async ( GCancellable $cancellable, GFileReadMoreCallback $read_more_callback, GAsyncReadyCallback $callback, Pointer $user_data )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$read_more_callback; (scope call) (closure user-data): a Gnome::Gio::FileReadMoreCallback to receive partial data and to specify whether further data should be read
$callback; (scope async) (closure user-data): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; the data to pass to the callback functions
load-partial-contents-finish
Finishes an asynchronous partial load operation that was started with load-partial-contents-async()
. The data is always zero-terminated, but this is not included in the resultant length. The returned content should be freed with g-free()
when no longer needed.
Returns: True
if the load was successful. If False
and error is present, it will be set appropriately.
method load-partial-contents-finish ( GAsyncResult $res, CArray[Str] $contents, UInt $length, CArray[Str] $etag_out, N-GError $error --> Bool )
$res; a Gnome::Gio::AsyncResult
$contents; (element-type guint8) (array length=length): a location to place the contents of the file
$length; a location to place the length of the contents of the file, or
undefined
if the length is not needed$etag_out; a location to place the current entity tag for the file, or
undefined
if the entity tag is not needed$error; a Gnome::Gio::Error, or
undefined
make-directory
Creates a directory. Note that this will only create a child directory of the immediate parent directory of the path or URI given by the Gnome::Gio::File. To recursively create directories, see make-directory-with-parents()
. This function will fail if the parent directory does not exist, setting error to G-IO-ERROR-NOT-FOUND
. If the file system doesn't support creating directories, this function will fail, setting error to G-IO-ERROR-NOT-SUPPORTED
.
For a local Gnome::Gio::File the newly created directory will have the default (current) ownership and permissions of the current process.
If cancellable is not undefined
, 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.
Returns: True
on successful creation, False
otherwise.
method make-directory ( GCancellable $cancellable, N-GError $error --> Bool )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
make-directory-async
Asynchronously creates a directory.
Virtual: make-directory-async
method make-directory-async ( Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; the data to pass to callback function
make-directory-finish
Finishes an asynchronous directory creation, started with make-directory-async()
.
Virtual: make-directory-finish
Returns: True
on successful directory creation, False
otherwise.
method make-directory-finish ( GAsyncResult $result, N-GError $error --> Bool )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
make-directory-with-parents
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 Gnome::Gio::File the newly created directories will have the default (current) ownership and permissions of the current process.
If cancellable is not undefined
, 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.
Returns: True
if all directories have been successfully created, False
otherwise.
method make-directory-with-parents ( GCancellable $cancellable, N-GError $error --> Bool )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
make-symbolic-link
Creates a symbolic link named file which contains the string symlink-value.
If cancellable is not undefined
, 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.
Returns: True
on the creation of a new symlink, False
otherwise.
method make-symbolic-link ( Str $symlink_value, GCancellable $cancellable, N-GError $error --> Bool )
$symlink_value; (type filename): a string with the path for the target of the new symlink
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error
measure-disk-usage
Recursively measures the disk usage of file.
This is essentially an analog of the 'du' command, but it also reports the number of directories and non-directory files encountered (including things like symbolic links).
By default, errors are only reported against the toplevel file itself. Errors found while recursing are silently ignored, unless G-FILE-DISK-USAGE-REPORT-ALL-ERRORS
is given in flags.
The returned size, disk-usage, is in bytes and should be formatted with g-format-size()
in order to get something reasonable for showing in a user interface.
progress-callback and progress-data can be given to request periodic progress updates while scanning. See the documentation for Gnome::Gio::FileMeasureProgressCallback for information about when and how the callback will be invoked.
Returns: True
if successful, with the out parameters set. False
otherwise, with error set.
method measure-disk-usage ( UInt $flags, GCancellable $cancellable, GFileMeasureProgressCallback $progress_callback, Pointer $progress_data, UInt $disk_usage, UInt $num_dirs, UInt $num_files, N-GError $error --> Bool )
$flags; Gnome::Gio::FileMeasureFlags
$cancellable; optional Gnome::Gio::Cancellable
$progress_callback; a Gnome::Gio::FileMeasureProgressCallback
$progress_data; user-data for progress-callback
$disk_usage; the number of bytes of disk space used
$num_dirs; the number of directories encountered
$num_files; the number of non-directories encountered
$error;
undefined
, or a pointer to aundefined
Gnome::Gio::Error pointer
measure-disk-usage-async
Recursively measures the disk usage of file.
This is the asynchronous version of measure-disk-usage()
. See there for more information.
method measure-disk-usage-async ( UInt $flags, Int() $io_priority, GCancellable $cancellable, GFileMeasureProgressCallback $progress_callback, Pointer $progress_data, GAsyncReadyCallback $callback, Pointer $user_data )
$flags; Gnome::Gio::FileMeasureFlags
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable
$progress_callback; a Gnome::Gio::FileMeasureProgressCallback
$progress_data; user-data for progress-callback
$callback; a Gnome::Gio::AsyncReadyCallback to call when complete
$user_data; the data to pass to callback function
measure-disk-usage-finish
Collects the results from an earlier call to measure-disk-usage-async()
. See g-file-measure-disk-usage()
for more information.
Returns: True
if successful, with the out parameters set. False
otherwise, with error set.
method measure-disk-usage-finish ( GAsyncResult $result, UInt $disk_usage, UInt $num_dirs, UInt $num_files, N-GError $error --> Bool )
$result; the Gnome::Gio::AsyncResult passed to your Gnome::Gio::AsyncReadyCallback
$disk_usage; the number of bytes of disk space used
$num_dirs; the number of directories encountered
$num_files; the number of non-directories encountered
$error;
undefined
, or a pointer to aundefined
Gnome::Gio::Error pointer
monitor
Obtains a file or directory monitor for the given file, depending on the type of the file.
If cancellable is not undefined
, 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.
Returns: a Gnome::Gio::FileMonitor for the given file, or undefined
on error. Free the returned object with clear-object()
.
method monitor ( GFileMonitorFlags $flags, GCancellable $cancellable, N-GError $error --> GFileMonitor )
$flags; a set of Gnome::Gio::FileMonitorFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
monitor-directory
Obtains a directory monitor for the given file. This may fail if directory monitoring is not supported.
If cancellable is not undefined
, 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 monitor()
.
Virtual: monitor-dir
Returns: a Gnome::Gio::FileMonitor for the given file, or undefined
on error. Free the returned object with clear-object()
.
method monitor-directory ( GFileMonitorFlags $flags, GCancellable $cancellable, N-GError $error --> GFileMonitor )
$flags; a set of Gnome::Gio::FileMonitorFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
monitor-file
Obtains a file monitor for the given file. If no file notification mechanism exists, then regular polling of the file is used.
If cancellable is not undefined
, 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 flags contains G-FILE-MONITOR-WATCH-HARD-LINKS
then the monitor will also attempt to report changes made to the file via another filename (ie, a hard link). Without this flag, you can only rely on changes made through the filename contained in file to be reported. Using this flag may result in an increase in resource usage, and may not have any effect depending on the Gnome::Gio::FileMonitor backend and/or filesystem type.
Returns: a Gnome::Gio::FileMonitor for the given file, or undefined
on error. Free the returned object with clear-object()
.
method monitor-file ( GFileMonitorFlags $flags, GCancellable $cancellable, N-GError $error --> GFileMonitor )
$flags; a set of Gnome::Gio::FileMonitorFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
mount-enclosing-volume
Starts a mount-operation, mounting the volume that contains the file location.
When this operation has completed, callback will be called with user-user data, and the operation can be finalized with mount-enclosing-volume-finish()
.
If cancellable is not undefined
, 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.
method mount-enclosing-volume ( GMountMountFlags $flags, GMountOperation $mount_operation, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$flags; flags affecting the operation
$mount_operation; a Gnome::Gio::MountOperation or
undefined
to avoid user interaction$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied, or
undefined
$user_data; the data to pass to callback function
mount-enclosing-volume-finish
Finishes a mount operation started by mount-enclosing-volume()
.
Returns: True
if successful. If an error has occurred, this function will return False
and set error appropriately if present.
method mount-enclosing-volume-finish ( GAsyncResult $result, N-GError $error --> Bool )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
mount-mountable
Mounts a file of type G-FILE-TYPE-MOUNTABLE. Using mount-operation, you can request callbacks when, for instance, passwords are needed during authentication.
If cancellable is not undefined
, 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.
When the operation is finished, callback will be called. You can then call mount-mountable-finish()
to get the result of the operation.
method mount-mountable ( GMountMountFlags $flags, GMountOperation $mount_operation, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$flags; flags affecting the operation
$mount_operation; a Gnome::Gio::MountOperation, or
undefined
to avoid user interaction$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async) : a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied, or
undefined
$user_data; (closure): the data to pass to callback function
mount-mountable-finish
Finishes a mount operation. See mount-mountable()
for details.
Finish an asynchronous mount operation that was started with g-file-mount-mountable()
.
Returns: a Gnome::Gio::File or undefined
on error. Free the returned object with clear-object()
.
method mount-mountable-finish ( GAsyncResult $result, N-GError $error --> N-GFile )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
move
Tries to move the file or directory source to the location specified by destination. If native move operations are supported then this is used, otherwise a copy + delete fallback is used. The native implementation may support moving directories (for instance on moves inside the same filesystem), but the fallback code does not.
If the flag Gnome::Gio::-FILE-COPY-OVERWRITE is specified an already existing destination file is overwritten.
If the flag Gnome::Gio::-FILE-COPY-NOFOLLOW-SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.
If cancellable is not undefined
, 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 progress-callback is not undefined
, then the operation can be monitored by setting this to a Gnome::Gio::FileProgressCallback function. progress-callback-data will be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation.
If the source file does not exist, then the G-IO-ERROR-NOT-FOUND
error is returned, independent on the status of the destination.
If Gnome::Gio::-FILE-COPY-OVERWRITE is not specified and the target exists, then the error G-IO-ERROR-EXISTS
is returned.
If trying to overwrite a file over a directory, the G-IO-ERROR-IS-DIRECTORY
error is returned. If trying to overwrite a directory with a directory the G-IO-ERROR-WOULD-MERGE
error is returned.
If the source is a directory and the target does not exist, or Gnome::Gio::-FILE-COPY-OVERWRITE is specified and the target is a file, then the G-IO-ERROR-WOULD-RECURSE
error may be returned (if the native move operation isn't available).
Returns: True
on successful move, False
otherwise.
method move ( N-GFile $destination, UInt $flags, GCancellable $cancellable, GFileProgressCallback $progress_callback, Pointer $progress_callback_data, N-GError $error --> Bool )
$destination; Gnome::Gio::File pointing to the destination location
$flags; set of Gnome::Gio::FileCopyFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$progress_callback; (scope call): Gnome::Gio::FileProgressCallback function for updates
$progress_callback_data; (closure): gpointer to user data for the callback function
$error; Gnome::Gio::Error for returning error conditions, or
undefined
open-readwrite
Opens an existing file for reading and writing. The result is a Gnome::Gio::FileIOStream that can be used to read and write the contents of the file.
If cancellable is not undefined
, 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. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
Returns: Gnome::Gio::FileIOStream or undefined
on error. Free the returned object with clear-object()
.
method open-readwrite ( GCancellable $cancellable, N-GError $error --> GFileIOStream )
$cancellable; a Gnome::Gio::Cancellable
$error; a Gnome::Gio::Error, or
undefined
open-readwrite-async
method open-readwrite-async ( Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$io_priority;
$cancellable;
$callback;
$user_data;
open-readwrite-finish
Finishes an asynchronous file read operation started with open-readwrite-async()
.
Returns: a Gnome::Gio::FileIOStream or undefined
on error. Free the returned object with clear-object()
.
method open-readwrite-finish ( GAsyncResult $res, N-GError $error --> GFileIOStream )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
parse-name
Constructs a Gnome::Gio::File with the given parse-name (i.e. something given by get-parse-name()
). This operation never fails, but the returned object might not support any I/O operation if the parse-name cannot be parsed.
Returns: a new Gnome::Gio::File.
method parse-name ( Str $parse_name --> N-GFile )
$parse_name; a file name or path to be parsed
peek-path
Exactly like 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.
Returns: (type filename) : string containing the Gnome::Gio::File's path, or undefined
if no such path exists. The returned string is owned by file.
method peek-path ( --> Str )
poll-mountable
Polls a file of type Gnome::Gio::-FILE-TYPE-MOUNTABLE.
If cancellable is not undefined
, 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.
When the operation is finished, callback will be called. You can then call mount-mountable-finish()
to get the result of the operation.
method poll-mountable ( GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied, or
undefined
$user_data; the data to pass to callback function
poll-mountable-finish
Finishes a poll operation. See poll-mountable()
for details.
Finish an asynchronous poll operation that was polled with g-file-poll-mountable()
.
Returns: True
if the operation finished successfully. False
otherwise.
method poll-mountable-finish ( GAsyncResult $result, N-GError $error --> Bool )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
query-default-handler
Returns the Gnome::Gio::AppInfo that is registered as the default application to handle the file specified by file.
If cancellable is not undefined
, 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.
Returns: a Gnome::Gio::AppInfo if the handle was found, undefined
if there were errors and $.last-error
becomes valid. When you are done with it, release it with clear-object()
method query-default-handler ( N-GObject $cancellable --> Gnome::Gio::AppInfo )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore. (TODO: Cancellable not defined yet)
query-default-handler-async
Async version of query-default-handler()
.
method query-default-handler-async ( Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$io_priority; optional Gnome::Gio::Cancellable object,
undefined
to ignore$cancellable; a Gnome::Gio::AsyncReadyCallback to call when the request is done
$callback; data to pass to callback
$user_data;
query-default-handler-finish
Finishes a query-default-handler-async()
operation.
Returns: a Gnome::Gio::AppInfo if the handle was found, undefined
if there were errors. When you are done with it, release it with clear-object()
method query-default-handler-finish ( GAsyncResult $result, N-GError $error --> GAppInfo )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error
query-exists
Utility function to check if a particular file exists. This is implemented using query-info()
and as such does blocking I/O.
Note that in many cases it is [racy to first check for file existence](https://en.wikipedia.org/wiki/Time-of-check-to-time-of-use) 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.
Returns: True
if the file exists (and can be detected without error), False
otherwise (or if cancelled).
method query-exists ( GCancellable $cancellable --> Bool )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore
query-file-type
Utility function to inspect the Gnome::Gio::FileType of a file. This is implemented using 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.
Returns: The Gnome::Gio::FileType of the file and Gnome::Gio::-FILE-TYPE-UNKNOWN if the file does not exist
method query-file-type ( GFileQueryInfoFlags $flags, GCancellable $cancellable --> GFileType )
$flags; a set of Gnome::Gio::FileQueryInfoFlags passed to
query-info()
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore
query-filesystem-info
Similar to query-info()
, but obtains information about the filesystem the file is on, rather than the file itself. For instance the amount of space available and the type of the filesystem.
The attributes value is a string that specifies the attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. attributes should be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "filesystem::*" means all attributes in the filesystem namespace. The standard namespace for filesystem attributes is "filesystem". Common attributes of interest are Gnome::Gio::-FILE-ATTRIBUTE-FILESYSTEM-SIZE (the total size of the filesystem in bytes), Gnome::Gio::-FILE-ATTRIBUTE-FILESYSTEM-FREE (number of bytes available), and Gnome::Gio::-FILE-ATTRIBUTE-FILESYSTEM-TYPE (type of the filesystem).
If cancellable is not undefined
, 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.
Returns: a Gnome::Gio::FileInfo or undefined
if there was an error. Free the returned object with clear-object()
.
method query-filesystem-info ( Str $attributes, GCancellable $cancellable, N-GError $error --> GFileInfo )
$attributes; an attribute query string
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error
query-filesystem-info-async
Asynchronously gets the requested information about the filesystem that the specified file is on. The result is a Gnome::Gio::FileInfo object that contains key-value attributes (such as type or size for the file).
For more details, see query-filesystem-info()
which is the synchronous version of this call.
When the operation is finished, callback will be called. You can then call g-file-query-info-finish()
to get the result of the operation.
method query-filesystem-info-async ( Str $attributes, Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$attributes; an attribute query string
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
query-filesystem-info-finish
Finishes an asynchronous filesystem info query. See query-filesystem-info-async()
.
Returns: Gnome::Gio::FileInfo for given file or undefined
on error. Free the returned object with clear-object()
.
method query-filesystem-info-finish ( GAsyncResult $res, N-GError $error --> GFileInfo )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error
query-info
Gets the requested information about specified file. The result is a Gnome::Gio::FileInfo object that contains key-value attributes (such as the type or size of the file).
The attributes value is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. attributes should be a comma-separated list of attributes 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 available as defines, like Gnome::Gio::-FILE-ATTRIBUTE-STANDARD-NAME.
If cancellable is not undefined
, 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 Gnome::Gio::-FILE-QUERY-INFO-NOFOLLOW-SYMLINKS in flags the information about the symlink itself will be returned. Also, for symlinks that point 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.
Returns: a Gnome::Gio::FileInfo for the given file, or undefined
on error. Free the returned object with clear-object()
.
method query-info ( Str $attributes, GFileQueryInfoFlags $flags, GCancellable $cancellable, N-GError $error --> GFileInfo )
$attributes; an attribute query string
$flags; a set of GFileQueryInfoFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore
query-info-async
Asynchronously gets the requested information about specified file. The result is a Gnome::Gio::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, callback will be called. You can then call g-file-query-info-finish()
to get the result of the operation.
method query-info-async ( Str $attributes, GFileQueryInfoFlags $flags, Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$attributes; an attribute query string
$flags; a set of Gnome::Gio::FileQueryInfoFlags
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
query-info-finish
Finishes an asynchronous file info query. See query-info-async()
.
Returns: Gnome::Gio::FileInfo for given file or undefined
on error. Free the returned object with clear-object()
.
method query-info-finish ( GAsyncResult $res, N-GError $error --> GFileInfo )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error
query-settable-attributes
Obtain the list of settable attributes for the file.
Returns the type and full attribute name of all the attributes that can be set on this file. This doesn't mean setting it will always succeed though, you might get an access failure, or some specific file may not support a specific attribute.
If cancellable is not undefined
, 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.
Returns: a Gnome::Gio::FileAttributeInfoList describing the settable attributes. When you are done with it, release it with attribute-info-list-unref()
method query-settable-attributes ( GCancellable $cancellable, N-GError $error --> GFileAttributeInfoList )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
query-writable-namespaces
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 undefined
, 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.
Returns: a Gnome::Gio::FileAttributeInfoList describing the writable namespaces. When you are done with it, release it with attribute-info-list-unref()
method query-writable-namespaces ( GCancellable $cancellable, N-GError $error --> GFileAttributeInfoList )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
read
Opens a file for reading. The result is a Gnome::Gio::FileInputStream that can be used to read the contents of the file.
If cancellable is not undefined
, 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.
Virtual: read-fn
Returns: Gnome::Gio::FileInputStream or undefined
on error. Free the returned object with clear-object()
.
method read ( GCancellable $cancellable, N-GError $error --> GFileInputStream )
$cancellable; a Gnome::Gio::Cancellable
$error; a Gnome::Gio::Error, or
undefined
read-async
Asynchronously opens file for reading.
For more details, see read()
which is the synchronous version of this call.
When the operation is finished, callback will be called. You can then call g-file-read-finish()
to get the result of the operation.
method read-async ( Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
read-finish
Finishes an asynchronous file read operation started with read-async()
.
Returns: a Gnome::Gio::FileInputStream or undefined
on error. Free the returned object with clear-object()
.
method read-finish ( GAsyncResult $res, N-GError $error --> GFileInputStream )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
replace
Returns an output stream for overwriting the file, possibly creating a backup copy of the file first. If the file doesn't exist, it will be created.
This will try to replace the file in the safest way possible so that any errors during the writing will not affect an already existing copy of the file. For instance, for local files it may write to a temporary file and then atomically rename over the destination when the stream is closed.
By default files created are generally readable by everyone, but if you pass Gnome::Gio::-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 undefined
, 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 you pass in a non-undefined
etag value and file already exists, then this value is compared to the current entity tag of the file, and if they differ an G-IO-ERROR-WRONG-ETAG
error is returned. This generally means that the file has been changed since you last read it. You can get the new etag from output-stream-get-etag()
after you've finished writing and closed the Gnome::Gio::FileOutputStream. When you load a new file you can use g-file-input-stream-query-info()
to get the etag of the file.
If make-backup is True
, this function will attempt to make a backup of the current file before overwriting it. If this fails a G-IO-ERROR-CANT-CREATE-BACKUP
error will be returned. If you want to replace anyway, try again with make-backup set to False
.
If the file is a directory the G-IO-ERROR-IS-DIRECTORY
error will be returned, and if the file is some other form of non-regular file then a G-IO-ERROR-NOT-REGULAR-FILE
error will be returned. Some file systems don't allow all file names, 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.
Returns: a Gnome::Gio::FileOutputStream or undefined
on error. Free the returned object with clear-object()
.
method replace ( Str $etag, Bool $make_backup, UInt $flags, GCancellable $cancellable, N-GError $error --> GFileOutputStream )
$etag; an optional [entity tag][gfile-etag] for the current Gnome::Gio::File, or NULL to ignore
$make_backup;
True
if a backup should be created$flags; a set of Gnome::Gio::FileCreateFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
replace-async
Asynchronously 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, callback will be called. You can then call g-file-replace-finish()
to get the result of the operation.
method replace-async ( Str $etag, Bool $make_backup, UInt $flags, Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$etag; an [entity tag][gfile-etag] for the current Gnome::Gio::File, or
undefined
to ignore$make_backup;
True
if a backup should be created$flags; a set of Gnome::Gio::FileCreateFlags
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
replace-contents
Replaces the contents of file with contents of length bytes.
If etag is specified (not undefined
), 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 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 undefined
, 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.
Returns: True
if successful. If an error has occurred, this function will return False
and set error appropriately if present.
method replace-contents ( Str $contents, UInt $length, Str $etag, Bool $make_backup, UInt $flags, CArray[Str] $new_etag, GCancellable $cancellable, N-GError $error --> Bool )
$contents; (element-type guint8) (array length=length): a string containing the new contents for file
$length; the length of contents in bytes
$etag; the old [entity-tag][gfile-etag] for the document, or
undefined
$make_backup;
True
if a backup should be created$flags; a set of Gnome::Gio::FileCreateFlags
$new_etag; a location to a new [entity tag][gfile-etag] for the document. This should be freed with
g-free()
when no longer needed, orundefined
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
replace-contents-async
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 replace-contents-finish()
.
If cancellable is not undefined
, 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 content will be made, so it must stay valid until callback is called. See g-file-replace-contents-bytes-async()
for a Gnome::Gio::Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.
method replace-contents-async ( Str $contents, UInt $length, Str $etag, Bool $make_backup, UInt $flags, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$contents; (element-type guint8) (array length=length): string of contents to replace the file with
$length; the length of contents in bytes
$etag; a new [entity tag][gfile-etag] for the file, or
undefined
$make_backup;
True
if a backup should be created$flags; a set of Gnome::Gio::FileCreateFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; the data to pass to callback function
replace-contents-bytes-async
Same as replace-contents-async()
but takes a Gnome::Gio::Bytes 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()
.
method replace-contents-bytes-async ( N-GObject $contents, Str $etag, Bool $make_backup, self._get-native-object-no-reffing $flags, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$contents; a Gnome::Gio::Bytes
$etag; a new [entity tag][gfile-etag] for the file, or
undefined
$make_backup;
True
if a backup should be created$flags; a set of Gnome::Gio::FileCreateFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; the data to pass to callback function
replace-contents-finish
Finishes an asynchronous replace of the given file. See replace-contents-async()
. Sets new-etag to the new entity tag for the document, if present.
Returns: True
on success, False
on failure.
method replace-contents-finish ( GAsyncResult $res, CArray[Str] $new_etag, N-GError $error --> Bool )
$res; a Gnome::Gio::AsyncResult
$new_etag; a location of a new [entity tag][gfile-etag] for the document. This should be freed with
g-free()
when it is no longer needed, orundefined
$error; a Gnome::Gio::Error, or
undefined
replace-finish
Finishes an asynchronous file replace operation started with replace-async()
.
Returns: a Gnome::Gio::FileOutputStream, or undefined
on error. Free the returned object with clear-object()
.
method replace-finish ( GAsyncResult $res, N-GError $error --> GFileOutputStream )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
replace-readwrite
Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first. If the file doesn't exist, it will be created.
For details about the behaviour, see replace()
which does the same thing but returns an output stream only.
Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
Returns: a Gnome::Gio::FileIOStream or undefined
on error. Free the returned object with clear-object()
.
method replace-readwrite ( Str $etag, Bool $make_backup, self._get-native-object-no-reffing $flags, GCancellable $cancellable, N-GError $error --> GFileIOStream )
$etag; an optional [entity tag][gfile-etag] for the current Gnome::Gio::File, or NULL to ignore
$make_backup;
True
if a backup should be created$flags; a set of Gnome::Gio::FileCreateFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; return location for a Gnome::Gio::Error, or
undefined
replace-readwrite-async
Asynchronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.
For more details, see replace-readwrite()
which is the synchronous version of this call.
When the operation is finished, callback will be called. You can then call g-file-replace-readwrite-finish()
to get the result of the operation.
method replace-readwrite-async ( Str $etag, Bool $make_backup, self._get-native-object-no-reffing $flags, Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$etag; an [entity tag][gfile-etag] for the current Gnome::Gio::File, or
undefined
to ignore$make_backup;
True
if a backup should be created$flags; a set of Gnome::Gio::FileCreateFlags
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
replace-readwrite-finish
Finishes an asynchronous file replace operation started with replace-readwrite-async()
.
Returns: a Gnome::Gio::FileIOStream, or undefined
on error. Free the returned object with clear-object()
.
method replace-readwrite-finish ( GAsyncResult $res, N-GError $error --> GFileIOStream )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
resolve-relative-path
Resolves a relative path for file to an absolute path.
This call does no blocking I/O.
Returns: Gnome::Gio::File to the resolved path. undefined
if relative-path is undefined
or if file is invalid. Free the returned object with clear-object()
.
method resolve-relative-path ( Str $relative_path --> N-GFile )
$relative_path; (type filename): a given relative path string
set-attribute
Sets an attribute in the file with attribute name attribute to value.
Some attributes can be unset by setting type to G-FILE-ATTRIBUTE-TYPE-INVALID
and value-p to undefined
.
If cancellable is not undefined
, 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.
Returns: True
if the attribute was set, False
otherwise.
method set-attribute ( Str $attribute, GFileAttributeType $type, Pointer $value_p, GFileQueryInfoFlags $flags, GCancellable $cancellable, N-GError $error --> Bool )
$attribute; a string containing the attribute's name
$type; The type of the attribute
$value_p; a pointer to the value (or the pointer itself if the type is a pointer type)
$flags; a set of Gnome::Gio::FileQueryInfoFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
set-attribute-byte-string
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 undefined
, 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.
Returns: True
if the attribute was successfully set to value in the file, False
otherwise.
method set-attribute-byte-string ( Str $attribute, Str $value, GFileQueryInfoFlags $flags, GCancellable $cancellable, N-GError $error --> Bool )
$attribute; a string containing the attribute's name
$value; a string containing the attribute's new value
$flags; a Gnome::Gio::FileQueryInfoFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
set-attribute-int32
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 undefined
, 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.
Returns: True
if the attribute was successfully set to value in the file, False
otherwise.
method set-attribute-int32 ( Str $attribute, Int() $value, GFileQueryInfoFlags $flags, GCancellable $cancellable, N-GError $error --> Bool )
$attribute; a string containing the attribute's name
$value; a gint32 containing the attribute's new value
$flags; a Gnome::Gio::FileQueryInfoFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
set-attribute-int64
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 undefined
, 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.
Returns: True
if the attribute was successfully set, False
otherwise.
method set-attribute-int64 ( Str $attribute, Int() $value, GFileQueryInfoFlags $flags, GCancellable $cancellable, N-GError $error --> Bool )
$attribute; a string containing the attribute's name
$value; a guint64 containing the attribute's new value
$flags; a Gnome::Gio::FileQueryInfoFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
set-attribute-string
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 undefined
, 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.
Returns: True
if the attribute was successfully set, False
otherwise.
method set-attribute-string ( Str $attribute, Str $value, GFileQueryInfoFlags $flags, GCancellable $cancellable, N-GError $error --> Bool )
$attribute; a string containing the attribute's name
$value; a string containing the attribute's value
$flags; Gnome::Gio::FileQueryInfoFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
set-attribute-uint32
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 undefined
, 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.
Returns: True
if the attribute was successfully set to value in the file, False
otherwise.
method set-attribute-uint32 ( Str $attribute, UInt $value, GFileQueryInfoFlags $flags, GCancellable $cancellable, N-GError $error --> Bool )
$attribute; a string containing the attribute's name
$value; a guint32 containing the attribute's new value
$flags; a Gnome::Gio::FileQueryInfoFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
set-attribute-uint64
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 undefined
, 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.
Returns: True
if the attribute was successfully set to value in the file, False
otherwise.
method set-attribute-uint64 ( Str $attribute, UInt $value, GFileQueryInfoFlags $flags, GCancellable $cancellable, N-GError $error --> Bool )
$attribute; a string containing the attribute's name
$value; a guint64 containing the attribute's new value
$flags; a Gnome::Gio::FileQueryInfoFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
set-attributes-async
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, callback will be called. You can then call g-file-set-attributes-finish()
to get the result of the operation.
method set-attributes-async ( GFileInfo $info, GFileQueryInfoFlags $flags, Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$info; a Gnome::Gio::FileInfo
$flags; a Gnome::Gio::FileQueryInfoFlags
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback
$user_data; (closure): a gpointer
set-attributes-finish
Finishes setting an attribute started in set-attributes-async()
.
Returns: True
if the attributes were set correctly, False
otherwise.
method set-attributes-finish ( GAsyncResult $result, GFileInfo $info, N-GError $error --> Bool )
$result; a Gnome::Gio::AsyncResult
$info; a Gnome::Gio::FileInfo
$error; a Gnome::Gio::Error, or
undefined
set-attributes-from-info
Tries to set all attributes in the Gnome::Gio::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 undefined
, 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.
Returns: False
if there was any error, True
otherwise.
method set-attributes-from-info ( GFileInfo $info, GFileQueryInfoFlags $flags, GCancellable $cancellable, N-GError $error --> Bool )
$info; a Gnome::Gio::FileInfo
$flags; Gnome::Gio::FileQueryInfoFlags
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
set-display-name
Renames file to the specified display name.
The display name is converted from UTF-8 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 (Gnome::Gio::-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 set-display-name()
.
On success the resulting converted filename is returned.
If cancellable is not undefined
, 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.
Returns: a Gnome::Gio::File specifying what file was renamed to, or undefined
if there was an error. Free the returned object with clear-object()
.
method set-display-name ( Str $display_name, GCancellable $cancellable, N-GError $error --> N-GFile )
$display_name; a string
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
set-display-name-async
Asynchronously sets the display name for a given Gnome::Gio::File.
For more details, see set-display-name()
which is the synchronous version of this call.
When the operation is finished, callback will be called. You can then call g-file-set-display-name-finish()
to get the result of the operation.
method set-display-name-async ( Str $display_name, Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$display_name; a string
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async): a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; (closure): the data to pass to callback function
set-display-name-finish
Finishes setting a display name started with set-display-name-async()
.
Returns: a Gnome::Gio::File or undefined
on error. Free the returned object with clear-object()
.
method set-display-name-finish ( GAsyncResult $res, N-GError $error --> N-GFile )
$res; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
start-mountable
Starts a file of type Gnome::Gio::-FILE-TYPE-MOUNTABLE. Using start-operation, you can request callbacks when, for instance, passwords are needed during authentication.
If cancellable is not undefined
, 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.
When the operation is finished, callback will be called. You can then call mount-mountable-finish()
to get the result of the operation.
method start-mountable ( GDriveStartFlags $flags, GMountOperation $start_operation, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$flags; flags affecting the operation
$start_operation; a Gnome::Gio::MountOperation, or
undefined
to avoid user interaction$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied, or
undefined
$user_data; the data to pass to callback function
start-mountable-finish
Finishes a start operation. See start-mountable()
for details.
Finish an asynchronous start operation that was started with g-file-start-mountable()
.
Returns: True
if the operation finished successfully. False
otherwise.
method start-mountable-finish ( GAsyncResult $result, N-GError $error --> Bool )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
stop-mountable
Stops a file of type Gnome::Gio::-FILE-TYPE-MOUNTABLE.
If cancellable is not undefined
, 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.
When the operation is finished, callback will be called. You can then call stop-mountable-finish()
to get the result of the operation.
method stop-mountable ( GMountUnmountFlags $flags, GMountOperation $mount_operation, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$flags; flags affecting the operation
$mount_operation; a Gnome::Gio::MountOperation, or
undefined
to avoid user interaction.$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied, or
undefined
$user_data; the data to pass to callback function
stop-mountable-finish
Finishes an stop operation, see stop-mountable()
for details.
Finish an asynchronous stop operation that was started with g-file-stop-mountable()
.
Returns: True
if the operation finished successfully. False
otherwise.
method stop-mountable-finish ( GAsyncResult $result, N-GError $error --> Bool )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
supports-thread-contexts
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.
Returns: Whether or not file supports thread-default contexts.
method supports-thread-contexts ( --> Bool )
trash
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 file systems support trashing, so this call can return the G-IO-ERROR-NOT-SUPPORTED
error.
If cancellable is not undefined
, 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.
Virtual: trash
Returns: True
on successful trash, False
otherwise.
method trash ( GCancellable $cancellable, N-GError $error --> Bool )
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$error; a Gnome::Gio::Error, or
undefined
trash-async
Asynchronously sends file to the Trash location, if possible.
Virtual: trash-async
method trash-async ( Int() $io_priority, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$io_priority; the [I/O priority][io-priority] of the request
$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied
$user_data; the data to pass to callback function
trash-finish
Finishes an asynchronous file trashing operation, started with trash-async()
.
Virtual: trash-finish
Returns: True
on successful trash, False
otherwise.
method trash-finish ( GAsyncResult $result, N-GError $error --> Bool )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
unmount-mountable-with-operation
Unmounts a file of type Gnome::Gio::-FILE-TYPE-MOUNTABLE.
If cancellable is not undefined
, 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.
When the operation is finished, callback will be called. You can then call unmount-mountable-finish()
to get the result of the operation.
method unmount-mountable-with-operation ( GMountUnmountFlags $flags, GMountOperation $mount_operation, GCancellable $cancellable, GAsyncReadyCallback $callback, Pointer $user_data )
$flags; flags affecting the operation
$mount_operation; a Gnome::Gio::MountOperation, or
undefined
to avoid user interaction$cancellable; optional Gnome::Gio::Cancellable object,
undefined
to ignore$callback; (scope async) : a Gnome::Gio::AsyncReadyCallback to call when the request is satisfied, or
undefined
$user_data; (closure): the data to pass to callback function
unmount-mountable-with-operation-finish
Finishes an unmount operation, see unmount-mountable-with-operation()
for details.
Finish an asynchronous unmount operation that was started with g-file-unmount-mountable-with-operation()
.
Returns: True
if the operation finished successfully. False
otherwise.
method unmount-mountable-with-operation-finish ( GAsyncResult $result, N-GError $error --> Bool )
$result; a Gnome::Gio::AsyncResult
$error; a Gnome::Gio::Error, or
undefined
_g_file_new_build_filename
Constructs a Gnome::Gio::File from a series of elements using the correct separator for filenames.
Using this function is equivalent to calling g-build-filename()
, followed by new-for-path()
on the result.
Returns: a new Gnome::Gio::File
method _g_file_new_build_filename ( Str $first_element --> N-GFile )
$first_element; (type filename): the first element in the path @...: remaining elements in path, terminated by
undefined
_g_file_new_for_commandline_arg
Creates a Gnome::Gio::File with the 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.
Note that on Windows, this function expects its argument to be in UTF-8 -- not the system code page. This means that you should not use this function with string from argv as it is passed to main()
. g-win32-get-command-line()
will return a UTF-8 version of the commandline. Gnome::Gio::Application also uses UTF-8 but g-application-command-line-create-file-for-arg()
may be more useful for you there. It is also always possible to use this function with Gnome::Gio::OptionContext arguments of type G-OPTION-ARG-FILENAME
.
Returns: a new Gnome::Gio::File. Free the returned object with clear-object()
.
method _g_file_new_for_commandline_arg ( Str $arg --> N-GFile )
$arg; (type filename): a command line string
_g_file_new_for_commandline_arg_and_cwd
Creates a Gnome::Gio::File with the given argument from the command line.
This function is similar to new-for-commandline-arg()
except that it allows for passing the current working directory as an argument instead of using the current working directory of the process.
This is useful if the commandline argument was given in a context other than the invocation of the current process.
See also g-application-command-line-create-file-for-arg()
.
Returns: a new Gnome::Gio::File
method _g_file_new_for_commandline_arg_and_cwd ( Str $arg, Str $cwd --> N-GFile )
$arg; a command line string
$cwd; the current working directory of the commandline
_g_file_new_for_path
Constructs a Gnome::Gio::File for a given path. This operation never fails, but the returned object might not support any I/O operation if path is malformed.
Returns: a new Gnome::Gio::File for the given path. Free the returned object with clear-object()
.
method _g_file_new_for_path ( Str $path --> N-GFile )
$path; (type filename): a string containing a relative or absolute path. The string must be encoded in the glib filename encoding.
_g_file_new_for_uri
Constructs a Gnome::Gio::File for a given URI. This operation never fails, but the returned object might not support any I/O operation if uri is malformed or if the uri type is not supported.
Returns: a new Gnome::Gio::File for the given uri. Free the returned object with clear-object()
.
method _g_file_new_for_uri ( Str $uri --> N-GFile )
$uri; a UTF-8 string containing a URI
_g_file_new_tmp
Opens a file in the preferred directory for temporary files (as returned by g-get-tmp-dir()
) and returns a Gnome::Gio::File and Gnome::Gio::FileIOStream pointing to it.
tmpl should be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it is undefined
, a default template is used.
Unlike the other Gnome::Gio::File constructors, this will return undefined
if a temporary file could not be created.
Returns: a new Gnome::Gio::File. Free the returned object with clear-object()
.
method _g_file_new_tmp ( Str $tmpl, GFileIOStream $iostream, N-GError $error --> N-GFile )
$tmpl; (type filename) : Template for the file name, as in
open-tmp()
, orundefined
for a default template$iostream; on return, a Gnome::Gio::FileIOStream for the created file
$error; a Gnome::Gio::Error, or
undefined