-
public abstract FileOutputStream append_to (FileCreateFlags flags, Cancellable? cancellable = null) throws Error
Gets an output stream for appending data to the file. If the file doesn't already exist it is created.
-
public abstract async FileOutputStream append_to_async (FileCreateFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously opens file for appending.
-
public abstract bool copy (File destination, FileCopyFlags flags, Cancellable? cancellable = null, FileProgressCallback? progress_callback = null) throws Error
Copies the file source to the location specified by destination. Can not
handle recursive copies of directories.
-
public abstract async bool copy_async (File destination, FileCopyFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null, FileProgressCallback? progress_callback = null) throws Error
Copies the file source to the location specified by destination
asynchronously. For details of the behaviour, see copy.
-
public bool copy_attributes (File destination, FileCopyFlags flags, Cancellable? cancellable = null) throws Error
Copies the file attributes from source to destination.
-
public abstract FileOutputStream create (FileCreateFlags flags, Cancellable? cancellable = null) throws Error
Creates a new file and returns an output stream for writing to it. The file must not already exist.
-
public abstract async FileOutputStream create_async (FileCreateFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously creates a new file and returns an output stream for writing to it. The file must not
already exist.
-
public abstract weak FileIOStream create_readwrite (FileCreateFlags flags, Cancellable? cancellable = null) throws Error
Creates a new file and returns a stream for reading and writing to it. The file must not already exist.
-
public abstract async weak FileIOStream create_readwrite_async (FileCreateFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously creates a new file and returns a stream for reading and writing to it. The file must not
already exist.
-
public bool delete (Cancellable? cancellable = null) throws Error
Deletes a file. If the file is a directory, it will only be deleted if it is empty.
-
public abstract bool delete_file (Cancellable? cancellable = null) throws Error
Deletes a file. If the file is a directory, it will only be deleted if it is empty.
-
public abstract weak File dup ()
Duplicates a File handle. This operation does not
duplicate the actual file or directory represented by the File; see
copy if attempting to copy a file.
-
public abstract async bool eject_mountable (MountUnmountFlags flags, Cancellable? cancellable = null) throws Error
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_finish.
-
public abstract async bool eject_mountable_with_operation (MountUnmountFlags flags, MountOperation? mount_operation, Cancellable? cancellable = null) throws Error
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.
-
public abstract FileEnumerator enumerate_children (string attributes, FileQueryInfoFlags flags, Cancellable? cancellable = null) throws 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.
-
public abstract async FileEnumerator enumerate_children_async (string attributes, FileQueryInfoFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously 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.
-
public abstract bool equal (File file2)
Checks equality of two given Files. Note that two
Files that differ can still refer to the same file on the filesystem due to various
forms of filename aliasing.
-
public abstract Mount find_enclosing_mount (Cancellable? cancellable = null) throws Error
-
public abstract async Mount find_enclosing_mount_async (int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously gets the mount for the file.
-
public abstract string? get_basename ()
Gets the base name (the last component of the path) for a given
File.
-
public File get_child (string name)
Gets a child of file with basename equal to name.
-
public abstract File get_child_for_display_name (string display_name) throws Error
Gets the child of file for a given display_name (i.e. a UTF8 version of the
name). If this function fails, it returns null 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.
-
public abstract File? get_parent ()
Gets the parent directory for the file. If the file represents the root
directory of the file system, then null will be returned.
-
public abstract string get_parse_name ()
Gets the parse name of the file. A parse name is a UTF-8 string that describes the file
such that one can get the File back using
parse_name.
-
public abstract string? get_path ()
Gets the local pathname for File, if one exists.
-
public abstract string? get_relative_path (File descendant)
Gets the path for descendant relative to parent.
-
public abstract string get_uri ()
Gets the URI for the file.
-
public abstract string get_uri_scheme ()
Gets the URI scheme for a File. RFC 3986 decodes the
scheme as:
-
public bool has_parent (File? parent)
Checks if file has a parent, and optionally, if it is parent.
-
public bool has_prefix (File prefix)
Checks whether file has the prefix specified by prefix. In other word, if the
names of initial elements of files 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.
-
public abstract bool has_uri_scheme (string uri_scheme)
Checks to see if a File has a given URI scheme.
-
public abstract uint hash ()
Creates a hash value for a File.
-
public abstract bool is_native ()
Checks to see if a file is native to the platform.
-
public bool load_contents (Cancellable? cancellable = null, out uint8[] contents, out string etag_out = null) throws Error
Loads the content of the file into memory. The data is always zero-terminated, but this is not included
in the resultant length. The returned content should be freed with
g_free when no longer needed.
-
public async bool load_contents_async (Cancellable? cancellable = null, out uint8[] contents, out string etag_out = null) throws Error
Starts an asynchronous load of the file's contents.
-
public async bool load_partial_contents_async (Cancellable? cancellable, FileReadMoreCallback read_more_callback, out uint8[] contents, out string etag_out = null) throws Error
Reads the partial contents of a file. A
FileReadMoreCallback should be used to stop reading from the file when appropriate, else this function will behave exactly as
load_contents_async. This operation can be finished by
g_file_load_partial_contents_finish.
-
public abstract bool make_directory (Cancellable? cancellable = null) throws 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 File. To recursively create directories, see
make_directory_with_parents. This function will fail if the
parent directory does not exist, setting error to NOT_FOUND.
If the file system doesn't support creating directories, this function will fail, setting error to
NOT_SUPPORTED.
-
public bool make_directory_with_parents (Cancellable? cancellable = null) throws 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
NOT_SUPPORTED.
-
public abstract bool make_symbolic_link (string symlink_value, Cancellable? cancellable = null) throws Error
Creates a symbolic link named file which contains the string symlink_value.
-
public weak FileMonitor monitor (FileMonitorFlags flags, Cancellable? cancellable = null) throws Error
Obtains a file or directory monitor for the given file, depending on the type of the file.
-
public abstract FileMonitor monitor_directory (FileMonitorFlags flags, Cancellable? cancellable = null) throws IOError
Obtains a directory monitor for the given file. This may fail if directory monitoring is not supported.
-
public abstract FileMonitor monitor_file (FileMonitorFlags flags, Cancellable? cancellable = null) throws IOError
Obtains a file monitor for the given file. If no file notification mechanism exists, then regular
polling of the file is used.
-
public abstract async bool mount_enclosing_volume (MountMountFlags flags, MountOperation? mount_operation, Cancellable? cancellable = null) throws Error
Starts a mount_operation, mounting the volume that contains the file location.
-
public abstract async weak File mount_mountable (MountMountFlags flags, MountOperation? mount_operation, Cancellable? cancellable = null) throws Error
Mounts a file of type G_FILE_TYPE_MOUNTABLE. Using mount_operation, you can request
callbacks when, for instance, passwords are needed during authentication.
-
public abstract bool move (File destination, FileCopyFlags flags, Cancellable? cancellable = null, FileProgressCallback? progress_callback = null) throws Error
Tries to move the file or directory source to the location specified by destination
. If native move operations are supported then this is used, otherwise a copy + delete fallback is used. The native
implementation may support moving directories (for instance on moves inside the same filesystem), but the fallback code does not.
-
public abstract weak FileIOStream open_readwrite (Cancellable? cancellable = null) throws Error
Opens an existing file for reading and writing. The result is a
FileIOStream that can be used to read and write the contents of the file.
-
public abstract async weak FileIOStream open_readwrite_async (int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously opens file for reading and writing.
-
public abstract async bool poll_mountable (Cancellable? cancellable = null) throws Error
Polls a file of type G_FILE_TYPE_MOUNTABLE.
-
public abstract bool prefix_matches (File file)
Checks whether file has the prefix specified by prefix. In other word, if the
names of initial elements of files 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.
-
public AppInfo query_default_handler (Cancellable? cancellable = null) throws Error
Returns the AppInfo that is registered as the default
application to handle the file specified by file.
-
public bool query_exists (Cancellable? cancellable = null)
Utility function to check if a particular file exists. This is implemented using
query_info and as such does blocking I/O.
-
public FileType query_file_type (FileQueryInfoFlags flags, Cancellable? cancellable = null)
Utility function to inspect the FileType of a file. This
is implemented using query_info and as such does blocking I/O.
-
public abstract FileInfo query_filesystem_info (string attributes, Cancellable? cancellable = null) throws Error
Similar to query_info, but obtains
information about the filesystem the file is on, rather than the file itself. For instance the amount of space available
and the type of the filesystem.
-
public abstract async weak FileInfo query_filesystem_info_async (string attributes, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously gets the requested information about the filesystem that the specified file
is on. The result is a FileInfo object that contains key-value attributes (such as
type or size for the file).
-
public abstract FileInfo query_info (string attributes, FileQueryInfoFlags flags, Cancellable? cancellable = null) throws Error
Gets the requested information about specified file. The result is a
FileInfo object that contains key-value attributes (such as the type or size of the
file).
-
public abstract async FileInfo query_info_async (string attributes, FileQueryInfoFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously gets the requested information about specified file. The result is a
FileInfo object that contains key-value attributes (such as type or size for the file).
-
public abstract weak FileAttributeInfoList query_settable_attributes (Cancellable? cancellable = null) throws Error
Obtain the list of settable attributes for the file.
-
public abstract weak FileAttributeInfoList query_writable_namespaces (Cancellable? cancellable = null) throws 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).
-
public FileInputStream read (Cancellable? cancellable = null) throws Error
Opens a file for reading. The result is a
FileInputStream that can be used to read the contents of the file.
-
public abstract async FileInputStream read_async (int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously opens file for reading.
-
public abstract weak FileInputStream read_fn (Cancellable? cancellable = null) throws Error
Opens a file for reading. The result is a
FileInputStream that can be used to read the contents of the file.
-
public abstract FileOutputStream replace (string? etag, bool make_backup, FileCreateFlags flags, Cancellable? cancellable = null) throws 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.
-
public abstract async FileOutputStream replace_async (string? etag, bool make_backup, FileCreateFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the file
first.
-
public bool replace_contents (string contents, size_t length, string? etag, bool make_backup, FileCreateFlags flags, out string? new_etag, Cancellable? cancellable = null) throws Error
Replaces the contents of file with contents of length bytes. If
etag is specified (not null) any existing file must have that etag, or the error
WRONG_ETAG will be returned.
-
public async bool replace_contents_async (string contents, size_t length, string? etag, bool make_backup, FileCreateFlags flags, Cancellable? cancellable = null, out string? new_etag = null) throws Error
Starts an asynchronous replacement of file with the given contents of
length bytes. etag will replace the document's current entity tag.
-
public abstract weak FileIOStream replace_readwrite (string? etag, bool make_backup, FileCreateFlags flags, Cancellable? cancellable = null) throws 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.
-
public abstract async weak FileIOStream replace_readwrite_async (string? etag, bool make_backup, FileCreateFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously overwrites the file in read-write mode, replacing the contents, possibly creating a
backup copy of the file first.
-
public abstract File resolve_relative_path (string relative_path)
Resolves a relative path for file to an absolute path.
-
public abstract bool set_attribute (string attribute, FileAttributeType type, void* value_p, FileQueryInfoFlags flags, Cancellable? cancellable = null) throws Error
Sets an attribute in the file with attribute name attribute to value.
-
public bool set_attribute_byte_string (string attribute, string value, FileQueryInfoFlags flags, Cancellable? cancellable = null) throws Error
Sets attribute of type
BYTE_STRING to value. If attribute is of a different type, this operation will fail, returning
false.
-
public bool set_attribute_int32 (string attribute, int32 value, FileQueryInfoFlags flags, Cancellable? cancellable = null) throws Error
Sets attribute of type INT32
to value. If attribute is of a different type, this operation will fail.
-
public bool set_attribute_int64 (string attribute, int64 value, FileQueryInfoFlags flags, Cancellable? cancellable = null) throws Error
Sets attribute of type INT64
to value. If attribute is of a different type, this operation will fail.
-
public bool set_attribute_string (string attribute, string value, FileQueryInfoFlags flags, Cancellable? cancellable = null) throws Error
Sets attribute of type
STRING to value. If attribute is of a different type, this operation will fail.
-
public bool set_attribute_uint32 (string attribute, uint32 value, FileQueryInfoFlags flags, Cancellable? cancellable = null) throws Error
Sets attribute of type
UINT32 to value. If attribute is of a different type, this operation will fail.
-
public bool set_attribute_uint64 (string attribute, uint64 value, FileQueryInfoFlags flags, Cancellable? cancellable = null) throws Error
Sets attribute of type
UINT64 to value. If attribute is of a different type, this operation will fail.
-
public abstract async bool set_attributes_async (FileInfo info, FileQueryInfoFlags flags, int io_priority = DEFAULT, Cancellable? cancellable, out FileInfo info_out) throws Error
Asynchronously sets the attributes of file with info.
-
public abstract bool set_attributes_from_info (FileInfo info, FileQueryInfoFlags flags, Cancellable? cancellable = null) throws Error
Tries to set all attributes in the FileInfo on the target
values, not stopping on the first error.
-
public abstract weak File set_display_name (string display_name, Cancellable? cancellable = null) throws Error
Renames file to the specified display name.
-
public abstract async weak File set_display_name_async (string display_name, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asynchronously sets the display name for a given File.
-
public abstract async bool start_mountable (DriveStartFlags flags, MountOperation start_operation, Cancellable? cancellable = null) throws Error
Starts a file of type G_FILE_TYPE_MOUNTABLE. Using start_operation, you can request
callbacks when, for instance, passwords are needed during authentication.
-
public abstract async bool stop_mountable (MountUnmountFlags flags, MountOperation? mount_operation, Cancellable? cancellable = null) throws Error
Stops a file of type G_FILE_TYPE_MOUNTABLE.
-
public bool supports_thread_contexts ()
Checks if file supports thread-default
contexts. If this returns false, you cannot perform asynchronous operations on file in a thread
that has a thread-default context.
-
public abstract bool trash (Cancellable? cancellable = null) throws Error
Sends file to the "Trashcan", if possible. This is similar to deleting it, but the user can
recover it before emptying the trashcan. Not all file systems support trashing, so this call can return the
NOT_SUPPORTED error.
-
public abstract async bool unmount_mountable (MountUnmountFlags flags, Cancellable? cancellable = null) throws Error
Unmounts a file of type G_FILE_TYPE_MOUNTABLE.
-
public abstract async bool unmount_mountable_with_operation (MountUnmountFlags flags, MountOperation? mount_operation, Cancellable? cancellable = null) throws Error
Unmounts a file of type G_FILE_TYPE_MOUNTABLE.