pub trait FileExt: IsA<File> + Sealed + 'static {
Show 102 methods
// Provided methods
fn append_to(
&self,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileOutputStream, Error> { ... }
fn append_to_async<P: FnOnce(Result<FileOutputStream, Error>) + 'static>(
&self,
flags: FileCreateFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn append_to_future(
&self,
flags: FileCreateFlags,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<FileOutputStream, Error>> + 'static>> { ... }
fn build_attribute_list_for_copy(
&self,
flags: FileCopyFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<GString, Error> { ... }
fn copy(
&self,
destination: &impl IsA<File>,
flags: FileCopyFlags,
cancellable: Option<&impl IsA<Cancellable>>,
progress_callback: Option<&mut dyn FnMut(i64, i64)>,
) -> Result<(), Error> { ... }
fn copy_attributes(
&self,
destination: &impl IsA<File>,
flags: FileCopyFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn create(
&self,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileOutputStream, Error> { ... }
fn create_async<P: FnOnce(Result<FileOutputStream, Error>) + 'static>(
&self,
flags: FileCreateFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn create_future(
&self,
flags: FileCreateFlags,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<FileOutputStream, Error>> + 'static>> { ... }
fn create_readwrite(
&self,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileIOStream, Error> { ... }
fn create_readwrite_async<P: FnOnce(Result<FileIOStream, Error>) + 'static>(
&self,
flags: FileCreateFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn create_readwrite_future(
&self,
flags: FileCreateFlags,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<FileIOStream, Error>> + 'static>> { ... }
fn delete(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn delete_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn delete_future(
&self,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn dup(&self) -> File { ... }
fn eject_mountable_with_operation<P: FnOnce(Result<(), Error>) + 'static>(
&self,
flags: MountUnmountFlags,
mount_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn eject_mountable_with_operation_future(
&self,
flags: MountUnmountFlags,
mount_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn enumerate_children(
&self,
attributes: &str,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileEnumerator, Error> { ... }
fn equal(&self, file2: &impl IsA<File>) -> bool { ... }
fn find_enclosing_mount(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<Mount, Error> { ... }
fn basename(&self) -> Option<PathBuf> { ... }
fn child(&self, name: impl AsRef<Path>) -> File { ... }
fn child_for_display_name(&self, display_name: &str) -> Result<File, Error> { ... }
fn parent(&self) -> Option<File> { ... }
fn parse_name(&self) -> GString { ... }
fn path(&self) -> Option<PathBuf> { ... }
fn relative_path(&self, descendant: &impl IsA<File>) -> Option<PathBuf> { ... }
fn uri(&self) -> GString { ... }
fn uri_scheme(&self) -> Option<GString> { ... }
fn has_parent(&self, parent: Option<&impl IsA<File>>) -> bool { ... }
fn has_prefix(&self, prefix: &impl IsA<File>) -> bool { ... }
fn has_uri_scheme(&self, uri_scheme: &str) -> bool { ... }
fn is_native(&self) -> bool { ... }
fn load_bytes(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(Bytes, Option<GString>), Error> { ... }
fn load_bytes_async<P: FnOnce(Result<(Bytes, Option<GString>), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn load_bytes_future(
&self,
) -> Pin<Box_<dyn Future<Output = Result<(Bytes, Option<GString>), Error>> + 'static>> { ... }
fn make_directory(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn make_directory_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn make_directory_future(
&self,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn make_directory_with_parents(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn make_symbolic_link(
&self,
symlink_value: impl AsRef<Path>,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn monitor(
&self,
flags: FileMonitorFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileMonitor, Error> { ... }
fn monitor_directory(
&self,
flags: FileMonitorFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileMonitor, Error> { ... }
fn monitor_file(
&self,
flags: FileMonitorFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileMonitor, Error> { ... }
fn mount_enclosing_volume<P: FnOnce(Result<(), Error>) + 'static>(
&self,
flags: MountMountFlags,
mount_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn mount_enclosing_volume_future(
&self,
flags: MountMountFlags,
mount_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn mount_mountable<P: FnOnce(Result<File, Error>) + 'static>(
&self,
flags: MountMountFlags,
mount_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn mount_mountable_future(
&self,
flags: MountMountFlags,
mount_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>,
) -> Pin<Box_<dyn Future<Output = Result<File, Error>> + 'static>> { ... }
fn move_(
&self,
destination: &impl IsA<File>,
flags: FileCopyFlags,
cancellable: Option<&impl IsA<Cancellable>>,
progress_callback: Option<&mut dyn FnMut(i64, i64)>,
) -> Result<(), Error> { ... }
fn open_readwrite(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileIOStream, Error> { ... }
fn open_readwrite_async<P: FnOnce(Result<FileIOStream, Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn open_readwrite_future(
&self,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<FileIOStream, Error>> + 'static>> { ... }
fn peek_path(&self) -> Option<PathBuf> { ... }
fn poll_mountable<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn poll_mountable_future(
&self,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn query_default_handler(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<AppInfo, Error> { ... }
fn query_default_handler_async<P: FnOnce(Result<AppInfo, Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn query_default_handler_future(
&self,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<AppInfo, Error>> + 'static>> { ... }
fn query_exists(&self, cancellable: Option<&impl IsA<Cancellable>>) -> bool { ... }
fn query_file_type(
&self,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> FileType { ... }
fn query_filesystem_info(
&self,
attributes: &str,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileInfo, Error> { ... }
fn query_filesystem_info_async<P: FnOnce(Result<FileInfo, Error>) + 'static>(
&self,
attributes: &str,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn query_filesystem_info_future(
&self,
attributes: &str,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<FileInfo, Error>> + 'static>> { ... }
fn query_info(
&self,
attributes: &str,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileInfo, Error> { ... }
fn query_info_async<P: FnOnce(Result<FileInfo, Error>) + 'static>(
&self,
attributes: &str,
flags: FileQueryInfoFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn query_info_future(
&self,
attributes: &str,
flags: FileQueryInfoFlags,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<FileInfo, Error>> + 'static>> { ... }
fn query_settable_attributes(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileAttributeInfoList, Error> { ... }
fn query_writable_namespaces(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileAttributeInfoList, Error> { ... }
fn read(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileInputStream, Error> { ... }
fn read_async<P: FnOnce(Result<FileInputStream, Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn read_future(
&self,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<FileInputStream, Error>> + 'static>> { ... }
fn replace(
&self,
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileOutputStream, Error> { ... }
fn replace_async<P: FnOnce(Result<FileOutputStream, Error>) + 'static>(
&self,
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn replace_future(
&self,
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<FileOutputStream, Error>> + 'static>> { ... }
fn replace_contents(
&self,
contents: &[u8],
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<Option<GString>, Error> { ... }
fn replace_readwrite(
&self,
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileIOStream, Error> { ... }
fn replace_readwrite_async<P: FnOnce(Result<FileIOStream, Error>) + 'static>(
&self,
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn replace_readwrite_future(
&self,
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<FileIOStream, Error>> + 'static>> { ... }
fn resolve_relative_path(&self, relative_path: impl AsRef<Path>) -> File { ... }
fn set_attribute_byte_string(
&self,
attribute: &str,
value: &str,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn set_attribute_int32(
&self,
attribute: &str,
value: i32,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn set_attribute_int64(
&self,
attribute: &str,
value: i64,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn set_attribute_string(
&self,
attribute: &str,
value: &str,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn set_attribute_uint32(
&self,
attribute: &str,
value: u32,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn set_attribute_uint64(
&self,
attribute: &str,
value: u64,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn set_attributes_async<P: FnOnce(Result<FileInfo, Error>) + 'static>(
&self,
info: &FileInfo,
flags: FileQueryInfoFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn set_attributes_future(
&self,
info: &FileInfo,
flags: FileQueryInfoFlags,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<FileInfo, Error>> + 'static>> { ... }
fn set_attributes_from_info(
&self,
info: &FileInfo,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn set_display_name(
&self,
display_name: &str,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<File, Error> { ... }
fn set_display_name_async<P: FnOnce(Result<File, Error>) + 'static>(
&self,
display_name: &str,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn set_display_name_future(
&self,
display_name: &str,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<File, Error>> + 'static>> { ... }
fn start_mountable<P: FnOnce(Result<(), Error>) + 'static>(
&self,
flags: DriveStartFlags,
start_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn start_mountable_future(
&self,
flags: DriveStartFlags,
start_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn stop_mountable<P: FnOnce(Result<(), Error>) + 'static>(
&self,
flags: MountUnmountFlags,
mount_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn stop_mountable_future(
&self,
flags: MountUnmountFlags,
mount_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn supports_thread_contexts(&self) -> bool { ... }
fn trash(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn trash_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn trash_future(
&self,
io_priority: Priority,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn unmount_mountable_with_operation<P: FnOnce(Result<(), Error>) + 'static>(
&self,
flags: MountUnmountFlags,
mount_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn unmount_mountable_with_operation_future(
&self,
flags: MountUnmountFlags,
mount_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
}
Provided Methods§
sourcefn append_to(
&self,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileOutputStream, Error>
fn append_to( &self, flags: FileCreateFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileOutputStream, Error>
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 FileCreateFlags::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 None
, then the operation can be cancelled
by triggering the cancellable object from another thread. If the
operation was cancelled, the error IOErrorEnum::Cancelled
will be
returned.
Some file systems don’t allow all file names, and may return an
IOErrorEnum::InvalidFilename
error. If the file is a directory the
IOErrorEnum::IsDirectory
error will be returned. Other errors are
possible too, and depend on what kind of filesystem the file is on.
§flags
a set of #GFileCreateFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileOutputStream, or None
on error.
Free the returned object with g_object_unref().
sourcefn append_to_async<P: FnOnce(Result<FileOutputStream, Error>) + 'static>(
&self,
flags: FileCreateFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn append_to_async<P: FnOnce(Result<FileOutputStream, Error>) + 'static>( &self, flags: FileCreateFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously opens @self for appending.
For more details, see g_file_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.
§flags
a set of #GFileCreateFlags
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn append_to_future( &self, flags: FileCreateFlags, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<FileOutputStream, Error>> + 'static>>
fn build_attribute_list_for_copy( &self, flags: FileCopyFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<GString, Error>
v2_68
only.fn copy( &self, destination: &impl IsA<File>, flags: FileCopyFlags, cancellable: Option<&impl IsA<Cancellable>>, progress_callback: Option<&mut dyn FnMut(i64, i64)>, ) -> Result<(), Error>
sourcefn copy_attributes(
&self,
destination: &impl IsA<File>,
flags: FileCopyFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn copy_attributes( &self, destination: &impl IsA<File>, flags: FileCopyFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Copies the file attributes from @self 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 FileCopyFlags::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.
§destination
a #GFile to copy attributes to
§flags
a set of #GFileCopyFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
true
if the attributes were copied successfully,
false
otherwise.
sourcefn create(
&self,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileOutputStream, Error>
fn create( &self, flags: FileCreateFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileOutputStream, Error>
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 FileCreateFlags::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 None
, then the operation can be cancelled
by triggering the cancellable object from another thread. If the
operation was cancelled, the error IOErrorEnum::Cancelled
will be
returned.
If a file or directory with this name already exists the
IOErrorEnum::Exists
error will be returned. Some file systems don’t
allow all file names, and may return an IOErrorEnum::InvalidFilename
error, and if the name is to long IOErrorEnum::FilenameTooLong
will
be returned. Other errors are possible too, and depend on what kind
of filesystem the file is on.
§flags
a set of #GFileCreateFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileOutputStream for the newly created
file, or None
on error.
Free the returned object with g_object_unref().
sourcefn create_async<P: FnOnce(Result<FileOutputStream, Error>) + 'static>(
&self,
flags: FileCreateFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn create_async<P: FnOnce(Result<FileOutputStream, Error>) + 'static>( &self, flags: FileCreateFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously creates a new file and returns an output stream for writing to it. The file must not already exist.
For more details, see g_file_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.
§flags
a set of #GFileCreateFlags
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn create_future( &self, flags: FileCreateFlags, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<FileOutputStream, Error>> + 'static>>
sourcefn create_readwrite(
&self,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileIOStream, Error>
fn create_readwrite( &self, flags: FileCreateFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileIOStream, Error>
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 FileCreateFlags::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 None
, then the operation can be cancelled
by triggering the cancellable object from another thread. If the
operation was cancelled, the error IOErrorEnum::Cancelled
will be
returned.
If a file or directory with this name already exists, the
IOErrorEnum::Exists
error will be returned. Some file systems don’t
allow all file names, and may return an IOErrorEnum::InvalidFilename
error, and if the name is too long, IOErrorEnum::FilenameTooLong
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.
§flags
a set of #GFileCreateFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileIOStream for the newly created
file, or None
on error.
Free the returned object with g_object_unref().
sourcefn create_readwrite_async<P: FnOnce(Result<FileIOStream, Error>) + 'static>(
&self,
flags: FileCreateFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn create_readwrite_async<P: FnOnce(Result<FileIOStream, Error>) + 'static>( &self, flags: FileCreateFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
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 g_file_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.
§flags
a set of #GFileCreateFlags
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn create_readwrite_future( &self, flags: FileCreateFlags, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<FileIOStream, Error>> + 'static>>
sourcefn delete(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn delete( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Deletes a file. If the @self is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().
If @self doesn’t exist, IOErrorEnum::NotFound
will be returned. This allows
for deletion to be implemented avoiding
time-of-check to time-of-use races:
g_autoptr(GError) local_error = NULL;
if (!g_file_delete (my_file, my_cancellable, &local_error) &&
!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
// deletion failed for some reason other than the file not existing:
// so report the error
g_warning ("Failed to delete %s: %s",
g_file_peek_path (my_file), local_error->message);
}
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
sourcefn delete_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn delete_async<P: FnOnce(Result<(), Error>) + 'static>( &self, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously delete a file. If the @self is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn delete_future( &self, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn dup(&self) -> File
fn dup(&self) -> File
Duplicates a #GFile handle. This operation does not duplicate the actual file or directory represented by the #GFile; see g_file_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 (#GFile 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 #GFile that is a duplicate of the given #GFile.
sourcefn eject_mountable_with_operation<P: FnOnce(Result<(), Error>) + 'static>(
&self,
flags: MountUnmountFlags,
mount_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn eject_mountable_with_operation<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
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 g_file_eject_mountable_with_operation_finish().
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§flags
flags affecting the operation
§mount_operation
a #GMountOperation,
or None
to avoid user interaction
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn eject_mountable_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn enumerate_children(
&self,
attributes: &str,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileEnumerator, Error>
fn enumerate_children( &self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileEnumerator, Error>
Gets the requested information about the files in a directory. The result is a #GFileEnumerator object that will give out #GFileInfo objects for all the files in the directory.
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
FILE_ATTRIBUTE_STANDARD_NAME
. FILE_ATTRIBUTE_STANDARD_NAME
should
always be specified if you plan to call g_file_enumerator_get_child() or
g_file_enumerator_iterate() on the returned enumerator.
If @cancellable is not None
, then the operation can be cancelled
by triggering the cancellable object from another thread. If the
operation was cancelled, the error IOErrorEnum::Cancelled
will be
returned.
If the file does not exist, the IOErrorEnum::NotFound
error will
be returned. If the file is not a directory, the IOErrorEnum::NotDirectory
error will be returned. Other errors are possible too.
§attributes
an attribute query string
§flags
a set of #GFileQueryInfoFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
A #GFileEnumerator if successful,
None
on error. Free the returned object with g_object_unref().
fn equal(&self, file2: &impl IsA<File>) -> bool
sourcefn find_enclosing_mount(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<Mount, Error>
fn find_enclosing_mount( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<Mount, Error>
Gets a #GMount for the #GFile.
#GMount is returned only for user interesting locations, see
#GVolumeMonitor. If the #GFileIface for @self does not have a #mount,
@error will be set to IOErrorEnum::NotFound
and None
#will be returned.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GMount where the @self is located
or None
on error.
Free the returned object with g_object_unref().
sourcefn basename(&self) -> Option<PathBuf>
fn basename(&self) -> Option<PathBuf>
Gets the base name (the last component of the path) for a given #GFile.
If called for the top level of a system (such as the filesystem root or a uri like sftp://host/) it will return a single directory separator (and on Windows, possibly a drive letter).
The base name is a byte string (not UTF-8). It has no defined encoding
or rules other than it may not contain zero bytes. If you want to use
filenames in a user interface you should use the display name that you
can get by requesting the FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
attribute with g_file_query_info().
This call does no blocking I/O.
§Returns
string containing the #GFile’s
base name, or None
if given #GFile is invalid. The returned string
should be freed with g_free() when no longer needed.
sourcefn child(&self, name: impl AsRef<Path>) -> File
fn child(&self, name: impl AsRef<Path>) -> File
Gets a child of @self with basename equal to @name.
Note that the file with that specific name might not exist, but you can still have a #GFile that points to it. You can use this for instance to create that file.
This call does no blocking I/O.
§name
string containing the child’s basename
§Returns
a #GFile to a child specified by @name. Free the returned object with g_object_unref().
sourcefn child_for_display_name(&self, display_name: &str) -> Result<File, Error>
fn child_for_display_name(&self, display_name: &str) -> Result<File, Error>
Gets the child of @self for a given @display_name (i.e. a UTF-8
version of the name). If this function fails, it returns None
and @error will be set. This is very useful when constructing a
#GFile for a new file and the user entered the filename in the
user interface, for instance when you select a directory and
type a filename in the file selector.
This call does no blocking I/O.
§display_name
string to a possible child
§Returns
a #GFile to the specified child, or
None
if the display name couldn’t be converted.
Free the returned object with g_object_unref().
sourcefn parent(&self) -> Option<File>
fn parent(&self) -> Option<File>
Gets the parent directory for the @self.
If the @self represents the root directory of the
file system, then None
will be returned.
This call does no blocking I/O.
§Returns
a #GFile structure to the
parent of the given #GFile or None
if there is no parent. Free
the returned object with g_object_unref().
sourcefn parse_name(&self) -> GString
fn parse_name(&self) -> GString
Gets the parse name of the @self. A parse name is a UTF-8 string that describes the file such that one can get the #GFile back using g_file_parse_name().
This is generally used to show the #GFile as a nice full-pathname kind of string in a user interface, like in a location entry.
For local files with names that can safely be converted to UTF-8 the pathname is used, otherwise the IRI is used (a form of URI that allows UTF-8 characters unescaped).
This call does no blocking I/O.
§Returns
a string containing the #GFile’s parse name. The returned string should be freed with g_free() when no longer needed.
sourcefn path(&self) -> Option<PathBuf>
fn path(&self) -> Option<PathBuf>
Gets the local pathname for #GFile, if one exists. If non-None
, this is
guaranteed to be an absolute, canonical path. It might contain symlinks.
This call does no blocking I/O.
§Returns
string containing the #GFile’s path,
or None
if no such path exists. The returned string should be freed
with g_free() when no longer needed.
sourcefn uri(&self) -> GString
fn uri(&self) -> GString
Gets the URI for the @self.
This call does no blocking I/O.
§Returns
a string containing the #GFile’s URI. If the #GFile was constructed with an invalid URI, an invalid URI is returned. The returned string should be freed with g_free() when no longer needed.
sourcefn uri_scheme(&self) -> Option<GString>
fn uri_scheme(&self) -> Option<GString>
Gets the URI scheme for a #GFile. RFC 3986 decodes the scheme as:
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
Common schemes include “file”, “http”, “ftp”, etc.
The scheme can be different from the one used to construct the #GFile, in that it might be replaced with one that is logically equivalent to the #GFile.
This call does no blocking I/O.
§Returns
a string containing the URI scheme for the given
#GFile or None
if the #GFile was constructed with an invalid URI. The
returned string should be freed with g_free() when no longer needed.
sourcefn has_parent(&self, parent: Option<&impl IsA<File>>) -> bool
fn has_parent(&self, parent: Option<&impl IsA<File>>) -> bool
Checks if @self has a parent, and optionally, if it is @parent.
If @parent is None
then this function returns true
if @self has any
parent at all. If @parent is non-None
then true
is only returned
if @self is an immediate child of @parent.
§parent
the parent to check for, or None
§Returns
true
if @self is an immediate child of @parent (or any parent in
the case that @parent is None
).
sourcefn has_prefix(&self, prefix: &impl IsA<File>) -> bool
fn has_prefix(&self, prefix: &impl IsA<File>) -> bool
Checks whether @self has the prefix specified by @prefix.
In other words, if the names of initial elements of @self’s pathname match @prefix. Only full pathname elements are matched, so a path like /foo is not considered a prefix of /foobar, only of /foo/bar.
A #GFile is not a prefix of itself. If you want to check for equality, use g_file_equal().
This call does no I/O, as it works purely on names. As such it can
sometimes return false
even if @self is inside a @prefix (from a
filesystem point of view), because the prefix of @self is an alias
of @prefix.
§prefix
input #GFile
§Returns
true
if the @self’s parent, grandparent, etc is @prefix,
false
otherwise.
sourcefn has_uri_scheme(&self, uri_scheme: &str) -> bool
fn has_uri_scheme(&self, uri_scheme: &str) -> bool
sourcefn is_native(&self) -> bool
fn is_native(&self) -> bool
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 g_file_get_path() will still return a native path.
This call does no blocking I/O.
§Returns
true
if @self is native
sourcefn load_bytes(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(Bytes, Option<GString>), Error>
fn load_bytes( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(Bytes, Option<GString>), Error>
Loads the contents of @self and returns it as #GBytes.
If @self is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling g_file_load_contents() and g_bytes_new_take().
For resources, @etag_out will be set to None
.
The data contained in the resulting #GBytes is always zero-terminated, but this is not included in the #GBytes length. The resulting #GBytes should be freed with g_bytes_unref() when no longer in use.
§cancellable
a #GCancellable or None
§Returns
a #GBytes or None
and @error is set
§etag_out
a location to place the current
entity tag for the file, or None
if the entity tag is not needed
sourcefn load_bytes_async<P: FnOnce(Result<(Bytes, Option<GString>), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn load_bytes_async<P: FnOnce(Result<(Bytes, Option<GString>), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously loads the contents of @self as #GBytes.
If @self is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling g_file_load_contents_async() and g_bytes_new_take().
@callback should call g_file_load_bytes_finish() to get the result of this asynchronous operation.
See g_file_load_bytes() for more information.
§cancellable
a #GCancellable or None
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn load_bytes_future( &self, ) -> Pin<Box_<dyn Future<Output = Result<(Bytes, Option<GString>), Error>> + 'static>>
sourcefn make_directory(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn make_directory( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
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 #GFile.
To recursively create directories, see g_file_make_directory_with_parents().
This function will fail if the parent directory does not exist, setting
@error to IOErrorEnum::NotFound
. If the file system doesn’t support
creating directories, this function will fail, setting @error to
IOErrorEnum::NotSupported
.
For a local #GFile the newly created directory will have the default (current) ownership and permissions of the current process.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
sourcefn make_directory_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn make_directory_async<P: FnOnce(Result<(), Error>) + 'static>( &self, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
fn make_directory_future( &self, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn make_directory_with_parents(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn make_directory_with_parents( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
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
IOErrorEnum::NotSupported
. If the directory itself already exists,
this function will fail setting @error to IOErrorEnum::Exists
, unlike
the similar g_mkdir_with_parents().
For a local #GFile the newly created directories will have the default (current) ownership and permissions of the current process.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
true
if all directories have been successfully created, false
otherwise.
sourcefn make_symbolic_link(
&self,
symlink_value: impl AsRef<Path>,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn make_symbolic_link( &self, symlink_value: impl AsRef<Path>, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Creates a symbolic link named @self which contains the string @symlink_value.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§symlink_value
a string with the path for the target of the new symlink
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
sourcefn monitor(
&self,
flags: FileMonitorFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileMonitor, Error>
fn monitor( &self, flags: FileMonitorFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileMonitor, Error>
Obtains a file or directory monitor for the given file, depending on the type of the file.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§flags
a set of #GFileMonitorFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileMonitor for the given @self,
or None
on error.
Free the returned object with g_object_unref().
sourcefn monitor_directory(
&self,
flags: FileMonitorFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileMonitor, Error>
fn monitor_directory( &self, flags: FileMonitorFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileMonitor, Error>
Obtains a directory monitor for the given file. This may fail if directory monitoring is not supported.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
It does not make sense for @flags to contain
FileMonitorFlags::WATCH_HARD_LINKS
, since hard links can not be made to
directories. It is not possible to monitor all the files in a
directory for changes made via hard links; if you want to do this then
you must register individual watches with g_file_monitor().
§flags
a set of #GFileMonitorFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileMonitor for the given @self,
or None
on error. Free the returned object with g_object_unref().
sourcefn monitor_file(
&self,
flags: FileMonitorFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileMonitor, Error>
fn monitor_file( &self, flags: FileMonitorFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileMonitor, Error>
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 None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
If @flags contains FileMonitorFlags::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 @self to be
reported. Using this flag may result in an increase in resource
usage, and may not have any effect depending on the #GFileMonitor
backend and/or filesystem type.
§flags
a set of #GFileMonitorFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileMonitor for the given @self,
or None
on error.
Free the returned object with g_object_unref().
sourcefn mount_enclosing_volume<P: FnOnce(Result<(), Error>) + 'static>(
&self,
flags: MountMountFlags,
mount_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn mount_enclosing_volume<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Starts a @mount_operation, mounting the volume that contains the file @self.
When this operation has completed, @callback will be called with @user_user data, and the operation can be finalized with g_file_mount_enclosing_volume_finish().
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§flags
flags affecting the operation
§mount_operation
a #GMountOperation
or None
to avoid user interaction
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call
when the request is satisfied, or None
fn mount_enclosing_volume_future( &self, flags: MountMountFlags, mount_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn mount_mountable<P: FnOnce(Result<File, Error>) + 'static>(
&self,
flags: MountMountFlags,
mount_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn mount_mountable<P: FnOnce(Result<File, Error>) + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
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 None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
When the operation is finished, @callback will be called. You can then call g_file_mount_mountable_finish() to get the result of the operation.
§flags
flags affecting the operation
§mount_operation
a #GMountOperation,
or None
to avoid user interaction
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn mount_mountable_future( &self, flags: MountMountFlags, mount_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>, ) -> Pin<Box_<dyn Future<Output = Result<File, Error>> + 'static>>
fn move_( &self, destination: &impl IsA<File>, flags: FileCopyFlags, cancellable: Option<&impl IsA<Cancellable>>, progress_callback: Option<&mut dyn FnMut(i64, i64)>, ) -> Result<(), Error>
sourcefn open_readwrite(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileIOStream, Error>
fn open_readwrite( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileIOStream, Error>
Opens an existing file for reading and writing. The result is a #GFileIOStream that can be used to read and write the contents of the file.
If @cancellable is not None
, then the operation can be cancelled
by triggering the cancellable object from another thread. If the
operation was cancelled, the error IOErrorEnum::Cancelled
will be
returned.
If the file does not exist, the IOErrorEnum::NotFound
error will
be returned. If the file is a directory, the IOErrorEnum::IsDirectory
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.
§cancellable
a #GCancellable
§Returns
#GFileIOStream or None
on error.
Free the returned object with g_object_unref().
sourcefn open_readwrite_async<P: FnOnce(Result<FileIOStream, Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn open_readwrite_async<P: FnOnce(Result<FileIOStream, Error>) + 'static>( &self, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously opens @self for reading and writing.
For more details, see g_file_open_readwrite() which is the synchronous version of this call.
When the operation is finished, @callback will be called. You can then call g_file_open_readwrite_finish() to get the result of the operation.
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn open_readwrite_future( &self, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<FileIOStream, Error>> + 'static>>
sourcefn peek_path(&self) -> Option<PathBuf>
fn peek_path(&self) -> Option<PathBuf>
Exactly like g_file_get_path(), but caches the result via
g_object_set_qdata_full(). This is useful for example in C
applications which mix g_file_*
APIs with native ones. It
also avoids an extra duplicated string when possible, so will be
generally more efficient.
This call does no blocking I/O.
§Returns
string containing the #GFile’s path,
or None
if no such path exists. The returned string is owned by @self.
sourcefn poll_mountable<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn poll_mountable<P: FnOnce(Result<(), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Polls a file of type FileType::Mountable
.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
When the operation is finished, @callback will be called. You can then call g_file_mount_mountable_finish() to get the result of the operation.
§cancellable
optional #GCancellable object, None
to ignore
§callback
a #GAsyncReadyCallback to call
when the request is satisfied, or None
fn poll_mountable_future( &self, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn query_default_handler(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<AppInfo, Error>
fn query_default_handler( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<AppInfo, Error>
Returns the #GAppInfo that is registered as the default application to handle the file specified by @self.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§cancellable
optional #GCancellable object, None
to ignore
§Returns
a #GAppInfo if the handle was found,
None
if there were errors.
When you are done with it, release it with g_object_unref()
sourcefn query_default_handler_async<P: FnOnce(Result<AppInfo, Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
Available on crate feature v2_60
only.
fn query_default_handler_async<P: FnOnce(Result<AppInfo, Error>) + 'static>( &self, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
v2_60
only.fn query_default_handler_future( &self, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<AppInfo, Error>> + 'static>>
v2_60
only.sourcefn query_exists(&self, cancellable: Option<&impl IsA<Cancellable>>) -> bool
fn query_exists(&self, cancellable: Option<&impl IsA<Cancellable>>) -> bool
Utility function to check if a particular file exists. This is implemented using g_file_query_info() and as such does blocking I/O.
Note that in many cases it is racy to first check for file existence and then execute something based on the outcome of that, because the file might have been created or removed in between the operations. The general approach to handling that is to not check, but just do the operation and handle the errors as they come.
As an example of race-free checking, take the case of reading a file,
and if it doesn’t exist, creating it. There are two racy versions: read
it, and on error create it; and: check if it exists, if not create it.
These can both result in two processes creating the file (with perhaps
a partially written file as the result). The correct approach is to
always try to create the file with g_file_create() which will either
atomically create the file or fail with a IOErrorEnum::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.
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
true
if the file exists (and can be detected without error),
false
otherwise (or if cancelled).
sourcefn query_file_type(
&self,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> FileType
fn query_file_type( &self, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> FileType
Utility function to inspect the #GFileType of a file. This is implemented using g_file_query_info() and as such does blocking I/O.
The primary use case of this method is to check if a file is a regular file, directory, or symlink.
§flags
a set of #GFileQueryInfoFlags passed to g_file_query_info()
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
The #GFileType of the file and FileType::Unknown
if the file does not exist
sourcefn query_filesystem_info(
&self,
attributes: &str,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileInfo, Error>
fn query_filesystem_info( &self, attributes: &str, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileInfo, Error>
Similar to g_file_query_info(), but obtains information about the filesystem the @self 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
FILE_ATTRIBUTE_FILESYSTEM_SIZE
(the total size of the filesystem
in bytes), FILE_ATTRIBUTE_FILESYSTEM_FREE
(number of bytes available),
and FILE_ATTRIBUTE_FILESYSTEM_TYPE
(type of the filesystem).
If @cancellable is not None
, then the operation can be cancelled
by triggering the cancellable object from another thread. If the
operation was cancelled, the error IOErrorEnum::Cancelled
will be
returned.
If the file does not exist, the IOErrorEnum::NotFound
error will
be returned. Other errors are possible too, and depend on what
kind of filesystem the file is on.
§attributes
an attribute query string
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileInfo or None
if there was an error.
Free the returned object with g_object_unref().
sourcefn query_filesystem_info_async<P: FnOnce(Result<FileInfo, Error>) + 'static>(
&self,
attributes: &str,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn query_filesystem_info_async<P: FnOnce(Result<FileInfo, Error>) + 'static>( &self, attributes: &str, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously gets the requested information about the filesystem that the specified @self is on. The result is a #GFileInfo object that contains key-value attributes (such as type or size for the file).
For more details, see g_file_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.
§attributes
an attribute query string
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn query_filesystem_info_future( &self, attributes: &str, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<FileInfo, Error>> + 'static>>
sourcefn query_info(
&self,
attributes: &str,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileInfo, Error>
fn query_info( &self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileInfo, Error>
Gets the requested information about specified @self. The result is a #GFileInfo 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
FILE_ATTRIBUTE_STANDARD_NAME
.
If @cancellable is not None
, then the operation can be cancelled
by triggering the cancellable object from another thread. If the
operation was cancelled, the error IOErrorEnum::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 FileQueryInfoFlags::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 IOErrorEnum::NotFound
error will be
returned. Other errors are possible too, and depend on what kind of
filesystem the file is on.
§attributes
an attribute query string
§flags
a set of #GFileQueryInfoFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileInfo for the given @self, or None
on error. Free the returned object with g_object_unref().
sourcefn query_info_async<P: FnOnce(Result<FileInfo, Error>) + 'static>(
&self,
attributes: &str,
flags: FileQueryInfoFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn query_info_async<P: FnOnce(Result<FileInfo, Error>) + 'static>( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously gets the requested information about specified @self. The result is a #GFileInfo object that contains key-value attributes (such as type or size for the file).
For more details, see g_file_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.
§attributes
an attribute query string
§flags
a set of #GFileQueryInfoFlags
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn query_info_future( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<FileInfo, Error>> + 'static>>
sourcefn query_settable_attributes(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileAttributeInfoList, Error>
fn query_settable_attributes( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileAttributeInfoList, Error>
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 None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileAttributeInfoList describing the settable attributes. When you are done with it, release it with g_file_attribute_info_list_unref()
sourcefn query_writable_namespaces(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileAttributeInfoList, Error>
fn query_writable_namespaces( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileAttributeInfoList, Error>
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 None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileAttributeInfoList describing the writable namespaces. When you are done with it, release it with g_file_attribute_info_list_unref()
sourcefn read(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileInputStream, Error>
fn read( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileInputStream, Error>
Opens a file for reading. The result is a #GFileInputStream that can be used to read the contents of the file.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
If the file does not exist, the IOErrorEnum::NotFound
error will be
returned. If the file is a directory, the IOErrorEnum::IsDirectory
error will be returned. Other errors are possible too, and depend
on what kind of filesystem the file is on.
§cancellable
a #GCancellable
§Returns
#GFileInputStream or None
on error.
Free the returned object with g_object_unref().
sourcefn read_async<P: FnOnce(Result<FileInputStream, Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn read_async<P: FnOnce(Result<FileInputStream, Error>) + 'static>( &self, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously opens @self for reading.
For more details, see g_file_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.
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn read_future( &self, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<FileInputStream, Error>> + 'static>>
sourcefn replace(
&self,
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileOutputStream, Error>
fn replace( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileOutputStream, Error>
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 FileCreateFlags::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 None
, then the operation can be cancelled
by triggering the cancellable object from another thread. If the
operation was cancelled, the error IOErrorEnum::Cancelled
will be
returned.
If you pass in a non-None
@etag value and @self already exists, then
this value is compared to the current entity tag of the file, and if
they differ an IOErrorEnum::WrongEtag
error is returned. This
generally means that the file has been changed since you last read
it. You can get the new etag from g_file_output_stream_get_etag()
after you’ve finished writing and closed the #GFileOutputStream. 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 IOErrorEnum::CantCreateBackup
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 IOErrorEnum::IsDirectory
error will
be returned, and if the file is some other form of non-regular file
then a IOErrorEnum::NotRegularFile
error will be returned. Some
file systems don’t allow all file names, and may return an
IOErrorEnum::InvalidFilename
error, and if the name is to long
IOErrorEnum::FilenameTooLong
will be returned. Other errors are
possible too, and depend on what kind of filesystem the file is on.
§etag
an optional entity tag for the current #GFile, or #NULL to ignore
§make_backup
true
if a backup should be created
§flags
a set of #GFileCreateFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileOutputStream or None
on error.
Free the returned object with g_object_unref().
sourcefn replace_async<P: FnOnce(Result<FileOutputStream, Error>) + 'static>(
&self,
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn replace_async<P: FnOnce(Result<FileOutputStream, Error>) + 'static>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.
For more details, see g_file_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.
§etag
an entity tag for the current #GFile,
or None
to ignore
§make_backup
true
if a backup should be created
§flags
a set of #GFileCreateFlags
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn replace_future( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<FileOutputStream, Error>> + 'static>>
sourcefn replace_contents(
&self,
contents: &[u8],
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<Option<GString>, Error>
fn replace_contents( &self, contents: &[u8], etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<Option<GString>, Error>
Replaces the contents of @self with @contents of @length bytes.
If @etag is specified (not None
), any existing file must have that etag,
or the error IOErrorEnum::WrongEtag
will be returned.
If @make_backup is true
, this function will attempt to make a backup
of @self. Internally, it uses g_file_replace(), so will try to replace the
file contents in the safest way possible. For example, atomic renames are
used when replacing local files’ contents.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::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.
§contents
a string containing the new contents for @self
§etag
the old entity-tag for the document,
or None
§make_backup
true
if a backup should be created
§flags
a set of #GFileCreateFlags
§cancellable
optional #GCancellable object, None
to ignore
§Returns
true
if successful. If an error has occurred, this function
will return false
and set @error appropriately if present.
§new_etag
a location to a new entity tag
for the document. This should be freed with g_free() when no longer
needed, or None
sourcefn replace_readwrite(
&self,
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<FileIOStream, Error>
fn replace_readwrite( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<FileIOStream, Error>
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 g_file_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.
§etag
an optional entity tag for the current #GFile, or #NULL to ignore
§make_backup
true
if a backup should be created
§flags
a set of #GFileCreateFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFileIOStream or None
on error.
Free the returned object with g_object_unref().
sourcefn replace_readwrite_async<P: FnOnce(Result<FileIOStream, Error>) + 'static>(
&self,
etag: Option<&str>,
make_backup: bool,
flags: FileCreateFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn replace_readwrite_async<P: FnOnce(Result<FileIOStream, Error>) + 'static>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.
For more details, see g_file_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.
§etag
an entity tag for the current #GFile,
or None
to ignore
§make_backup
true
if a backup should be created
§flags
a set of #GFileCreateFlags
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn replace_readwrite_future( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<FileIOStream, Error>> + 'static>>
sourcefn resolve_relative_path(&self, relative_path: impl AsRef<Path>) -> File
fn resolve_relative_path(&self, relative_path: impl AsRef<Path>) -> File
sourcefn set_attribute_byte_string(
&self,
attribute: &str,
value: &str,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn set_attribute_byte_string( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Sets @attribute of type FileAttributeType::ByteString
to @value.
If @attribute is of a different type, this operation will fail,
returning false
.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§attribute
a string containing the attribute’s name
§value
a string containing the attribute’s new value
§flags
a #GFileQueryInfoFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
true
if the @attribute was successfully set to @value
in the @self, false
otherwise.
sourcefn set_attribute_int32(
&self,
attribute: &str,
value: i32,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn set_attribute_int32( &self, attribute: &str, value: i32, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Sets @attribute of type FileAttributeType::Int32
to @value.
If @attribute is of a different type, this operation will fail.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§attribute
a string containing the attribute’s name
§value
a #gint32 containing the attribute’s new value
§flags
a #GFileQueryInfoFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
true
if the @attribute was successfully set to @value
in the @self, false
otherwise.
sourcefn set_attribute_int64(
&self,
attribute: &str,
value: i64,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn set_attribute_int64( &self, attribute: &str, value: i64, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Sets @attribute of type FileAttributeType::Int64
to @value.
If @attribute is of a different type, this operation will fail.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§attribute
a string containing the attribute’s name
§value
a #guint64 containing the attribute’s new value
§flags
a #GFileQueryInfoFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
true
if the @attribute was successfully set, false
otherwise.
sourcefn set_attribute_string(
&self,
attribute: &str,
value: &str,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn set_attribute_string( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Sets @attribute of type FileAttributeType::String
to @value.
If @attribute is of a different type, this operation will fail.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§attribute
a string containing the attribute’s name
§value
a string containing the attribute’s value
§flags
#GFileQueryInfoFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
true
if the @attribute was successfully set, false
otherwise.
sourcefn set_attribute_uint32(
&self,
attribute: &str,
value: u32,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn set_attribute_uint32( &self, attribute: &str, value: u32, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Sets @attribute of type FileAttributeType::Uint32
to @value.
If @attribute is of a different type, this operation will fail.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§attribute
a string containing the attribute’s name
§value
a #guint32 containing the attribute’s new value
§flags
a #GFileQueryInfoFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
true
if the @attribute was successfully set to @value
in the @self, false
otherwise.
sourcefn set_attribute_uint64(
&self,
attribute: &str,
value: u64,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn set_attribute_uint64( &self, attribute: &str, value: u64, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Sets @attribute of type FileAttributeType::Uint64
to @value.
If @attribute is of a different type, this operation will fail.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§attribute
a string containing the attribute’s name
§value
a #guint64 containing the attribute’s new value
§flags
a #GFileQueryInfoFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
true
if the @attribute was successfully set to @value
in the @self, false
otherwise.
sourcefn set_attributes_async<P: FnOnce(Result<FileInfo, Error>) + 'static>(
&self,
info: &FileInfo,
flags: FileQueryInfoFlags,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn set_attributes_async<P: FnOnce(Result<FileInfo, Error>) + 'static>( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously sets the attributes of @self with @info.
For more details, see g_file_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.
§info
a #GFileInfo
§flags
a #GFileQueryInfoFlags
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn set_attributes_future( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<FileInfo, Error>> + 'static>>
sourcefn set_attributes_from_info(
&self,
info: &FileInfo,
flags: FileQueryInfoFlags,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn set_attributes_from_info( &self, info: &FileInfo, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Tries to set all attributes in the #GFileInfo 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
FileAttributeStatus::ErrorSetting
, which means you can
also detect further errors.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§info
a #GFileInfo
§flags
#GFileQueryInfoFlags
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
sourcefn set_display_name(
&self,
display_name: &str,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<File, Error>
fn set_display_name( &self, display_name: &str, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<File, Error>
Renames @self 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 @self is renamed to this.
If you want to implement a rename operation in the user interface the
edit name (FILE_ATTRIBUTE_STANDARD_EDIT_NAME
) should be used as the
initial value in the rename widget, and then the result after editing
should be passed to g_file_set_display_name().
On success the resulting converted filename is returned.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§display_name
a string
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
a #GFile specifying what @self was renamed to,
or None
if there was an error.
Free the returned object with g_object_unref().
sourcefn set_display_name_async<P: FnOnce(Result<File, Error>) + 'static>(
&self,
display_name: &str,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn set_display_name_async<P: FnOnce(Result<File, Error>) + 'static>( &self, display_name: &str, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously sets the display name for a given #GFile.
For more details, see g_file_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.
§display_name
a string
§io_priority
the [I/O priority][io-priority] of the request
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn set_display_name_future( &self, display_name: &str, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<File, Error>> + 'static>>
sourcefn start_mountable<P: FnOnce(Result<(), Error>) + 'static>(
&self,
flags: DriveStartFlags,
start_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn start_mountable<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: DriveStartFlags, start_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Starts a file of type FileType::Mountable
.
Using @start_operation, you can request callbacks when, for instance,
passwords are needed during authentication.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
When the operation is finished, @callback will be called. You can then call g_file_mount_mountable_finish() to get the result of the operation.
§flags
flags affecting the operation
§start_operation
a #GMountOperation, or None
to avoid user interaction
§cancellable
optional #GCancellable object, None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied, or None
fn start_mountable_future( &self, flags: DriveStartFlags, start_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn stop_mountable<P: FnOnce(Result<(), Error>) + 'static>(
&self,
flags: MountUnmountFlags,
mount_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn stop_mountable<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Stops a file of type FileType::Mountable
.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
When the operation is finished, @callback will be called. You can then call g_file_stop_mountable_finish() to get the result of the operation.
§flags
flags affecting the operation
§mount_operation
a #GMountOperation,
or None
to avoid user interaction.
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call
when the request is satisfied, or None
fn stop_mountable_future( &self, flags: MountUnmountFlags, mount_operation: Option<&(impl IsA<MountOperation> + Clone + 'static)>, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn supports_thread_contexts(&self) -> bool
fn supports_thread_contexts(&self) -> bool
sourcefn trash(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn trash( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Sends @self 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
IOErrorEnum::NotSupported
error. Since GLib 2.66, the x-gvfs-notrash
unix
mount option can be used to disable g_file_trash() support for certain
mounts, the IOErrorEnum::NotSupported
error will be returned in that case.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
§cancellable
optional #GCancellable object,
None
to ignore
§Returns
sourcefn trash_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn trash_async<P: FnOnce(Result<(), Error>) + 'static>( &self, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
fn trash_future( &self, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn unmount_mountable_with_operation<P: FnOnce(Result<(), Error>) + 'static>(
&self,
flags: MountUnmountFlags,
mount_operation: Option<&impl IsA<MountOperation>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn unmount_mountable_with_operation<P: FnOnce(Result<(), Error>) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA<MountOperation>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Unmounts a file of type FileType::Mountable
.
If @cancellable is not None
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnum::Cancelled
will be returned.
When the operation is finished, @callback will be called. You can then call g_file_unmount_mountable_finish() to get the result of the operation.
§flags
flags affecting the operation
§mount_operation
a #GMountOperation,
or None
to avoid user interaction
§cancellable
optional #GCancellable object,
None
to ignore
§callback
a #GAsyncReadyCallback to call when the request is satisfied