package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/ocgtk.gio/Ocgtk_gio/Gio/Wrappers/File/index.html

Module Wrappers.File

type t = [ `file ] Gobject.obj
val from_gobject : 'a Gobject.obj -> t
val unmount_mountable_with_operation_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes an unmount operation, see g_file_unmount_mountable_with_operation() for details.

Finish an asynchronous unmount operation that was started with g_file_unmount_mountable_with_operation().

val unmount_mountable_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes an unmount operation, see g_file_unmount_mountable() for details.

Finish an asynchronous unmount operation that was started with g_file_unmount_mountable().

val trash_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes an asynchronous file trashing operation, started with g_file_trash_async().

val trash : t -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Sends @file to the "Trashcan", if possible. This is similar to deleting it, but the user can recover it before emptying the trashcan. Not all file systems support trashing, so this call can return the %G_IO_ERROR_NOT_SUPPORTED error. Since GLib 2.66, the `x-gvfs-notrash` unix mount option can be used to disable g_file_trash() support for certain mounts, the %G_IO_ERROR_NOT_SUPPORTED error will be returned in that case.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val supports_thread_contexts : t -> bool

Checks if @file supports thread-default contextsg-main-context-push-thread-default-context. If this returns %FALSE, you cannot perform asynchronous operations on @file in a thread that has a thread-default context.

val stop_mountable_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes a stop operation, see g_file_stop_mountable() for details.

Finish an asynchronous stop operation that was started with g_file_stop_mountable().

val start_mountable_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes a start operation. See g_file_start_mountable() for details.

Finish an asynchronous start operation that was started with g_file_start_mountable().

val set_display_name_finish : t -> [ `async_result ] Gobject.obj -> (t, GError.t) result

Finishes setting a display name started with g_file_set_display_name_async().

val set_display_name : t -> string -> [ `cancellable | `object_ ] Gobject.obj option -> (t, GError.t) result

Renames @file to the specified display name.

The display name is converted from UTF-8 to the correct encoding for the target filesystem if possible and the @file is renamed to this.

If you want to implement a rename operation in the user interface the edit name (%G_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 %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val set_attributes_from_info : t -> [ `file_info | `object_ ] Gobject.obj -> Gio_enums.filequeryinfoflags -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

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 %G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING, which means you can also detect further errors.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val set_attribute_uint64 : t -> string -> UInt64.t -> Gio_enums.filequeryinfoflags -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT64 to @value. If @attribute is of a different type, this operation will fail.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val set_attribute_uint32 : t -> string -> UInt32.t -> Gio_enums.filequeryinfoflags -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT32 to @value. If @attribute is of a different type, this operation will fail.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val set_attribute_string : t -> string -> string -> Gio_enums.filequeryinfoflags -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_STRING to @value. If @attribute is of a different type, this operation will fail.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val set_attribute_int64 : t -> string -> int64 -> Gio_enums.filequeryinfoflags -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT64 to @value. If @attribute is of a different type, this operation will fail.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val set_attribute_int32 : t -> string -> Int32.t -> Gio_enums.filequeryinfoflags -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT32 to @value. If @attribute is of a different type, this operation will fail.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val set_attribute_byte_string : t -> string -> string -> Gio_enums.filequeryinfoflags -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING to @value. If @attribute is of a different type, this operation will fail, returning %FALSE.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val resolve_relative_path : t -> string -> t

Resolves a relative path for @file to an absolute path.

This call does no blocking I/O.

If the @relative_path is an absolute path name, the resolution is done absolutely (without taking @file path as base).

val replace_readwrite_finish : t -> [ `async_result ] Gobject.obj -> ([ `file_io_stream | `io_stream | `object_ ] Gobject.obj, GError.t) result

Finishes an asynchronous file replace operation started with g_file_replace_readwrite_async().

val replace_readwrite : t -> string option -> bool -> Gio_enums.filecreateflags -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_io_stream | `io_stream | `object_ ] Gobject.obj, GError.t) result

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.

val replace_finish : t -> [ `async_result ] Gobject.obj -> ([ `file_output_stream | `output_stream | `object_ ] Gobject.obj, GError.t) result

Finishes an asynchronous file replace operation started with g_file_replace_async().

val replace : t -> string option -> bool -> Gio_enums.filecreateflags -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_output_stream | `output_stream | `object_ ] Gobject.obj, GError.t) result

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 %G_FILE_CREATE_PRIVATE in @flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

If you pass in a non-%NULL @etag value and @file already exists, then this value is compared to the current entity tag of the file, and if they differ an %G_IO_ERROR_WRONG_ETAG error is returned. This generally means that the file has been changed since you last read it. You can get the new etag from 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 %G_IO_ERROR_CANT_CREATE_BACKUP error will be returned. If you want to replace anyway, try again with @make_backup set to %FALSE.

If the file is a directory the %G_IO_ERROR_IS_DIRECTORY error will be returned, and if the file is some other form of non-regular file then a %G_IO_ERROR_NOT_REGULAR_FILE error will be returned. Some file systems don't allow all file names, and may return an %G_IO_ERROR_INVALID_FILENAME error, and if the name is to long %G_IO_ERROR_FILENAME_TOO_LONG will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

val read_finish : t -> [ `async_result ] Gobject.obj -> ([ `file_input_stream | `input_stream | `object_ ] Gobject.obj, GError.t) result

Finishes an asynchronous file read operation started with g_file_read_async().

val read : t -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_input_stream | `input_stream | `object_ ] Gobject.obj, GError.t) result

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 %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be returned. If the file is a directory, the %G_IO_ERROR_IS_DIRECTORY error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

val query_writable_namespaces : t -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_attribute_info_list ] Gobject.obj, GError.t) result

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 %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val query_settable_attributes : t -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_attribute_info_list ] Gobject.obj, GError.t) result

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 %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val query_info_finish : t -> [ `async_result ] Gobject.obj -> ([ `file_info | `object_ ] Gobject.obj, GError.t) result

Finishes an asynchronous file info query. See g_file_query_info_async().

val query_info : t -> string -> Gio_enums.filequeryinfoflags -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_info | `object_ ] Gobject.obj, GError.t) result

Gets the requested information about specified @file. 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 %G_FILE_ATTRIBUTE_STANDARD_NAME.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

For symlinks, normally the information about the target of the symlink is returned, rather than information about the symlink itself. However if you pass %G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS in @flags the information about the symlink itself will be returned. Also, for symlinks that point to non-existing files the information about the symlink itself will be returned.

If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

val query_filesystem_info_finish : t -> [ `async_result ] Gobject.obj -> ([ `file_info | `object_ ] Gobject.obj, GError.t) result

Finishes an asynchronous filesystem info query. See g_file_query_filesystem_info_async().

val query_filesystem_info : t -> string -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_info | `object_ ] Gobject.obj, GError.t) result

Similar to g_file_query_info(), but obtains information about the filesystem the @file is on, rather than the file itself. For instance the amount of space available and the type of the filesystem.

The @attributes value is a string that specifies the attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. @attributes should be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "filesystem::*" means all attributes in the filesystem namespace. The standard namespace for filesystem attributes is "filesystem". Common attributes of interest are %G_FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem in bytes), %G_FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes available), and %G_FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem).

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

val query_file_type : t -> Gio_enums.filequeryinfoflags -> [ `cancellable | `object_ ] Gobject.obj option -> Gio_enums.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.

val query_exists : t -> [ `cancellable | `object_ ] Gobject.obj option -> 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(https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use) and then execute something based on the outcome of that, because the file might have been created or removed in between the operations. The general approach to handling that is to not check, but just do the operation and handle the errors as they come.

As an example of race-free checking, take the case of reading a file, and if it doesn't exist, creating it. There are two racy versions: read it, and on error create it; and: check if it exists, if not create it. These can both result in two processes creating the file (with perhaps a partially written file as the result). The correct approach is to always try to create the file with g_file_create() which will either atomically create the file or fail with a %G_IO_ERROR_EXISTS error.

However, in many cases an existence check is useful in a user interface, for instance to make a menu item sensitive/insensitive, so that you don't have to fool users that something is possible and then just show an error dialog. If you do this, you should make sure to also handle the errors that can happen due to races when you execute the operation.

val query_default_handler_finish : t -> [ `async_result ] Gobject.obj -> ([ `app_info ] Gobject.obj, GError.t) result

Finishes a g_file_query_default_handler_async() operation.

val query_default_handler : t -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `app_info ] Gobject.obj, GError.t) result

Returns the #GAppInfo that is registered as the default application to handle the file specified by @file.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val poll_mountable_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes a poll operation. See g_file_poll_mountable() for details.

Finish an asynchronous poll operation that was polled with g_file_poll_mountable().

val peek_path : t -> string option

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.

val open_readwrite_finish : t -> [ `async_result ] Gobject.obj -> ([ `file_io_stream | `io_stream | `object_ ] Gobject.obj, GError.t) result

Finishes an asynchronous file read operation started with g_file_open_readwrite_async().

val open_readwrite : t -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_io_stream | `io_stream | `object_ ] Gobject.obj, GError.t) result

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 %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be returned. If the file is a directory, the %G_IO_ERROR_IS_DIRECTORY error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

val move_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes an asynchronous file movement, started with g_file_move_async().

val mount_mountable_finish : t -> [ `async_result ] Gobject.obj -> (t, GError.t) result

Finishes a mount operation. See g_file_mount_mountable() for details.

Finish an asynchronous mount operation that was started with g_file_mount_mountable().

val mount_enclosing_volume_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes a mount operation started by g_file_mount_enclosing_volume().

val monitor_file : t -> Gio_enums.filemonitorflags -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_monitor | `object_ ] Gobject.obj, GError.t) result

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 %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

If @flags contains %G_FILE_MONITOR_WATCH_HARD_LINKS then the monitor will also attempt to report changes made to the file via another filename (ie, a hard link). Without this flag, you can only rely on changes made through the filename contained in @file to be reported. Using this flag may result in an increase in resource usage, and may not have any effect depending on the #GFileMonitor backend and/or filesystem type.

val monitor_directory : t -> Gio_enums.filemonitorflags -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_monitor | `object_ ] Gobject.obj, GError.t) result

Obtains a directory monitor for the given file. This may fail if directory monitoring is not supported.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

It does not make sense for @flags to contain %G_FILE_MONITOR_WATCH_HARD_LINKS, since hard links can not be made to directories. It is not possible to monitor all the files in a directory for changes made via hard links; if you want to do this then you must register individual watches with g_file_monitor().

val monitor : t -> Gio_enums.filemonitorflags -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_monitor | `object_ ] Gobject.obj, GError.t) result

Obtains a file or directory monitor for the given file, depending on the type of the file.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val measure_disk_usage_finish : t -> [ `async_result ] Gobject.obj -> (bool * UInt64.t * UInt64.t * UInt64.t, GError.t) result

Collects the results from an earlier call to g_file_measure_disk_usage_async(). See g_file_measure_disk_usage() for more information.

Finishes an asynchronous symbolic link creation, started with g_file_make_symbolic_link_async().

Creates a symbolic link named @file which contains the string @symlink_value.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val make_directory_with_parents : t -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Creates a directory and any parent directories that may not exist similar to 'mkdir -p'. If the file system does not support creating directories, this function will fail, setting @error to %G_IO_ERROR_NOT_SUPPORTED. If the directory itself already exists, this function will fail setting @error to %G_IO_ERROR_EXISTS, unlike the similar g_mkdir_with_parents().

For a local #GFile the newly created directories will have the default (current) ownership and permissions of the current process.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val make_directory_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes an asynchronous directory creation, started with g_file_make_directory_async().

val make_directory : t -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

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 %G_IO_ERROR_NOT_FOUND. If the file system doesn't support creating directories, this function will fail, setting @error to %G_IO_ERROR_NOT_SUPPORTED.

For a local #GFile the newly created directory will have the default (current) ownership and permissions of the current process.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val is_native : t -> 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.

val hash : t -> int

Creates a hash value for a #GFile.

This call does no blocking I/O.

val has_uri_scheme : t -> string -> bool

Checks to see if a #GFile has a given URI scheme.

This call does no blocking I/O.

val has_prefix : t -> t -> bool

Checks whether @file has the prefix specified by @prefix.

In other words, if the names of initial elements of @file's pathname match @prefix. Only full pathname elements are matched, so a path like /foo is not considered a prefix of /foobar, only of /foo/bar.

A #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 @file is inside a @prefix (from a filesystem point of view), because the prefix of @file is an alias of @prefix.

val has_parent : t -> t option -> bool

Checks if @file has a parent, and optionally, if it is @parent.

If @parent is %NULL then this function returns %TRUE if @file has any parent at all. If @parent is non-%NULL then %TRUE is only returned if @file is an immediate child of @parent.

val get_uri_scheme : t -> string option

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.

val get_uri : t -> string

Gets the URI for the @file.

This call does no blocking I/O.

val get_relative_path : t -> t -> string option

Gets the path for @descendant relative to @parent.

This call does no blocking I/O.

val get_path : t -> string option

Gets the local pathname for #GFile, if one exists. If non-%NULL, this is guaranteed to be an absolute, canonical path. It might contain symlinks.

This call does no blocking I/O.

val get_parse_name : t -> string

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 #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.

val get_parent : t -> t option

Gets the parent directory for the @file. If the @file represents the root directory of the file system, then %NULL will be returned.

This call does no blocking I/O.

val get_child_for_display_name : t -> string -> (t, GError.t) result

Gets the child of @file for a given @display_name (i.e. a UTF-8 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.

This call does no blocking I/O.

val get_child : t -> string -> t

Gets a child of @file 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.

val get_basename : t -> string option

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 %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info().

This call does no blocking I/O.

val find_enclosing_mount_finish : t -> [ `async_result ] Gobject.obj -> ([ `mount ] Gobject.obj, GError.t) result

Finishes an asynchronous find mount request. See g_file_find_enclosing_mount_async().

val find_enclosing_mount : t -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `mount ] Gobject.obj, GError.t) result

Gets a #GMount for the #GFile.

#GMount is returned only for user interesting locations, see #GVolumeMonitor. If the #GFileIface for @file does not have a #mount, @error will be set to %G_IO_ERROR_NOT_FOUND and %NULL #will be returned.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val equal : t -> t -> bool

Checks if the two given #GFiles refer to the same file.

Note that two #GFiles that differ can still refer to the same file on the filesystem due to various forms of filename aliasing.

This call does no blocking I/O.

val enumerate_children_finish : t -> [ `async_result ] Gobject.obj -> ([ `file_enumerator | `object_ ] Gobject.obj, GError.t) result

Finishes an async enumerate children operation. See g_file_enumerate_children_async().

val enumerate_children : t -> string -> Gio_enums.filequeryinfoflags -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_enumerator | `object_ ] Gobject.obj, GError.t) result

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 %G_FILE_ATTRIBUTE_STANDARD_NAME. %G_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 %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be returned. If the file is not a directory, the %G_IO_ERROR_NOT_DIRECTORY error will be returned. Other errors are possible too.

val eject_mountable_with_operation_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes an asynchronous eject operation started by g_file_eject_mountable_with_operation().

val eject_mountable_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes an asynchronous eject operation started by g_file_eject_mountable().

val dup : t -> t

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.

val delete_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes deleting a file started with g_file_delete_async().

val delete : t -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Deletes a file. If the @file is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().

If @file doesn’t exist, %G_IO_ERROR_NOT_FOUND will be returned. This allows for deletion to be implemented avoiding time-of-check to time-of-use races(https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use): | 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 %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

val create_readwrite_finish : t -> [ `async_result ] Gobject.obj -> ([ `file_io_stream | `io_stream | `object_ ] Gobject.obj, GError.t) result

Finishes an asynchronous file create operation started with g_file_create_readwrite_async().

val create_readwrite : t -> Gio_enums.filecreateflags -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_io_stream | `io_stream | `object_ ] Gobject.obj, GError.t) result

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 %G_FILE_CREATE_PRIVATE in @flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

If a file or directory with this name already exists, the %G_IO_ERROR_EXISTS error will be returned. Some file systems don't allow all file names, and may return an %G_IO_ERROR_INVALID_FILENAME error, and if the name is too long, %G_IO_ERROR_FILENAME_TOO_LONG will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

val create_finish : t -> [ `async_result ] Gobject.obj -> ([ `file_output_stream | `output_stream | `object_ ] Gobject.obj, GError.t) result

Finishes an asynchronous file create operation started with g_file_create_async().

val create : t -> Gio_enums.filecreateflags -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_output_stream | `output_stream | `object_ ] Gobject.obj, GError.t) result

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 %G_FILE_CREATE_PRIVATE in @flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

If a file or directory with this name already exists the %G_IO_ERROR_EXISTS error will be returned. Some file systems don't allow all file names, and may return an %G_IO_ERROR_INVALID_FILENAME error, and if the name is to long %G_IO_ERROR_FILENAME_TOO_LONG will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

val copy_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes copying the file started with g_file_copy_async().

val copy_attributes : t -> t -> Gio_enums.filecopyflags -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Copies the file attributes from @source to @destination.

Normally only a subset of the file attributes are copied, those that are copies in a normal file copy operation (which for instance does not include e.g. owner). However if %G_FILE_COPY_ALL_METADATA is specified in @flags, then all the metadata that is possible to copy is copied. This is useful when implementing move by copy + delete source.

val build_attribute_list_for_copy : t -> Gio_enums.filecopyflags -> [ `cancellable | `object_ ] Gobject.obj option -> (string, GError.t) result

Prepares the file attribute query string for copying to @file.

This function prepares an attribute query string to be passed to g_file_query_info() to get a list of attributes normally copied with the file (see g_file_copy_attributes() for the detailed description). This function is used by the implementation of g_file_copy_attributes() and is useful when one needs to query and set the attributes in two stages (e.g., for recursive move of a directory).

val append_to_finish : t -> [ `async_result ] Gobject.obj -> ([ `file_output_stream | `output_stream | `object_ ] Gobject.obj, GError.t) result

Finishes an asynchronous file append operation started with g_file_append_to_async().

val append_to : t -> Gio_enums.filecreateflags -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `file_output_stream | `output_stream | `object_ ] Gobject.obj, GError.t) result

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 %G_FILE_CREATE_PRIVATE in @flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

If @cancellable is not %NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

Some file systems don't allow all file names, and may return an %G_IO_ERROR_INVALID_FILENAME error. If the file is a directory the %G_IO_ERROR_IS_DIRECTORY error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.