pub trait FileExt: 'static {
Show 105 methods
// Required 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 load_contents(
&self,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(Vec<u8>, Option<GString>), Error>;
fn load_contents_async<P: FnOnce(Result<(Vec<u8>, Option<GString>), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
);
fn load_contents_future(
&self
) -> Pin<Box_<dyn Future<Output = Result<(Vec<u8>, 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>>;
}
Expand description
Required 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 FileCreateFlags
cancellable
optional Cancellable
object,
None
to ignore
Returns
a FileOutputStream
, 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 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 FileCreateFlags
io_priority
the [I/O priority][io-priority] of the request
cancellable
optional Cancellable
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>>
sourcefn build_attribute_list_for_copy(
&self,
flags: FileCopyFlags,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<GString, Error>
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 File
to copy attributes to
flags
a set of FileCopyFlags
cancellable
optional Cancellable
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 FileCreateFlags
cancellable
optional Cancellable
object,
None
to ignore
Returns
a FileOutputStream
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 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 FileCreateFlags
io_priority
the [I/O priority][io-priority] of the request
cancellable
optional Cancellable
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 FileCreateFlags
cancellable
optional Cancellable
object,
None
to ignore
Returns
a FileIOStream
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 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 FileCreateFlags
io_priority
the [I/O priority][io-priority] of the request
cancellable
optional Cancellable
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 Cancellable
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 Cancellable
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 File
handle. This operation does not duplicate
the actual file or directory represented by the File
; see
g_file_copy()
if attempting to copy a file.
dup()
is useful when a second handle is needed to the same underlying
file, for use in a separate thread (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
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 MountOperation
,
or None
to avoid user interaction
cancellable
optional Cancellable
object,
None
to ignore
callback
a GAsyncReadyCallback
to call
when the request is satisfied, or None
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 FileEnumerator
object that will give out
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
FILE_ATTRIBUTE_STANDARD_NAME
. FILE_ATTRIBUTE_STANDARD_NAME
should
always be specified if you plan to call FileEnumeratorExt::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 FileQueryInfoFlags
cancellable
optional Cancellable
object,
None
to ignore
Returns
A FileEnumerator
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>
Mount
is returned only for user interesting locations, see
VolumeMonitor
. 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 Cancellable
object,
None
to ignore
Returns
a Mount
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 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 FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
attribute with query_info()
.
This call does no blocking I/O.
Returns
string containing the File
’s
base name, or None
if given File
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 File
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 File
to a child specified by name
.
Free the returned object with g_object_unref()
.
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
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>
v2_56
only.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 )
v2_56
only.sourcefn load_bytes_future(
&self
) -> Pin<Box_<dyn Future<Output = Result<(Bytes, Option<GString>), Error>> + 'static>>
fn load_bytes_future( &self ) -> Pin<Box_<dyn Future<Output = Result<(Bytes, Option<GString>), Error>> + 'static>>
v2_56
only.fn load_contents( &self, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(Vec<u8>, Option<GString>), Error>
fn load_contents_async<P: FnOnce(Result<(Vec<u8>, Option<GString>), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
fn load_contents_future( &self ) -> Pin<Box_<dyn Future<Output = Result<(Vec<u8>, 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 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>
sourcefn 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_async<P: FnOnce(Result<AppInfo, Error>) + 'static>( &self, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
v2_60
only.sourcefn query_default_handler_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<AppInfo, Error>> + 'static>>
fn query_default_handler_future( &self, io_priority: Priority ) -> Pin<Box_<dyn Future<Output = Result<AppInfo, Error>> + 'static>>
v2_60
only.