File

gio.file.File is a high level abstraction for manipulating files on a virtual file system. gio.file.Files are lightweight, immutable objects that do no I/O upon creation. It is necessary to understand that gio.file.File objects do not represent files, merely an identifier for a file. All file content I/O is implemented as streaming operations (see gio.input_stream.InputStream and gio.output_stream.OutputStream).

To construct a gio.file.File, you can use:

One way to think of a gio.file.File is as an abstraction of a pathname. For normal files the system pathname is what is stored internally, but as gio.file.Files are extensible it could also be something else that corresponds to a pathname in a userspace implementation of a filesystem.

gio.file.Files make up hierarchies of directories and files that correspond to the files on a filesystem. You can move through the file system with gio.file.File using gio.file.File.getParent to get an identifier for the parent directory, gio.file.File.getChild to get a child within a directory, and gio.file.File.resolveRelativePath to resolve a relative path between two gio.file.Files. There can be multiple hierarchies, so you may not end up at the same root if you repeatedly call gio.file.File.getParent on two different files.

All gio.file.Files have a basename (get with gio.file.File.getBasename). These names are byte strings that are used to identify the file on the filesystem (relative to its parent directory) and there is no guarantees that they have any particular charset encoding or even make any sense at all. 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 gio.file.File.queryInfo. This is guaranteed to be in UTF-8 and can be used in a user interface. But always store the real basename or the gio.file.File to use to actually access the file, because there is no way to go from a display name to the actual name.

Using gio.file.File as an identifier has the same weaknesses as using a path in that there may be multiple aliases for the same file. For instance, hard or soft links may cause two different gio.file.Files to refer to the same file. Other possible causes for aliases are: case insensitive filesystems, short and long names on FAT/NTFS, or bind mounts in Linux. If you want to check if two gio.file.Files point to the same file you can query for the G_FILE_ATTRIBUTE_ID_FILE attribute. Note that gio.file.File does some trivial canonicalization of pathnames passed in, so that trivial differences in the path string used at creation (duplicated slashes, slash at end of path, . or .. path segments, etc) does not create different gio.file.Files.

Many gio.file.File operations have both synchronous and asynchronous versions to suit your application. Asynchronous versions of synchronous functions simply have _async() appended to their function names. The asynchronous I/O functions call a gio.types.AsyncReadyCallback which is then used to finalize the operation, producing a gio.async_result.AsyncResult which is then passed to the function’s matching _finish() operation.

It is highly recommended to use asynchronous calls when running within a shared main loop, such as in the main thread of an application. This avoids I/O operations blocking other sources on the main loop from being dispatched. Synchronous I/O operations should be performed from worker threads. See the introduction to asynchronous programming section

for more.

Some gio.file.File operations almost always take a noticeable amount of time, and so do not have synchronous analogs. Notable cases include:

Entity Tags

One notable feature of gio.file.Files are entity tags, or ‘etags’ for short. Entity tags are somewhat like a more abstract version of the traditional mtime, and can be used to quickly determine if the file has been modified from the version on the file system. See the HTTP 1.1 specification

for HTTP ETag headers, which are a very similar concept.

interface File {}

Members

Functions

appendTo
gio.file_output_stream.FileOutputStream appendTo(gio.types.FileCreateFlags flags, gio.cancellable.Cancellable cancellable)

Gets an output stream for appending data to the file. If the file doesn't already exist it is created.

appendToAsync
void appendToAsync(gio.types.FileCreateFlags flags, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously opens file for appending.

appendToFinish
gio.file_output_stream.FileOutputStream appendToFinish(gio.async_result.AsyncResult res)

Finishes an asynchronous file append operation started with gio.file.File.appendToAsync.

buildAttributeListForCopy
string buildAttributeListForCopy(gio.types.FileCopyFlags flags, gio.cancellable.Cancellable cancellable)

Prepares the file attribute query string for copying to file.

copy
bool copy(gio.file.File destination, gio.types.FileCopyFlags flags, gio.cancellable.Cancellable cancellable, gio.types.FileProgressCallback progressCallback)

Copies the file source to the location specified by destination. Can not handle recursive copies of directories.

copyAsync
void copyAsync(gio.file.File destination, gio.types.FileCopyFlags flags, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.FileProgressCallback progressCallback, gio.types.AsyncReadyCallback callback)

Copies the file source to the location specified by destination asynchronously. For details of the behaviour, see gio.file.File.copy.

copyAttributes
bool copyAttributes(gio.file.File destination, gio.types.FileCopyFlags flags, gio.cancellable.Cancellable cancellable)

Copies the file attributes from source to destination.

copyFinish
bool copyFinish(gio.async_result.AsyncResult res)

Finishes copying the file started with gio.file.File.copyAsync.

create
gio.file_output_stream.FileOutputStream create(gio.types.FileCreateFlags flags, gio.cancellable.Cancellable cancellable)

Creates a new file and returns an output stream for writing to it. The file must not already exist.

createAsync
void createAsync(gio.types.FileCreateFlags flags, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously creates a new file and returns an output stream for writing to it. The file must not already exist.

createFinish
gio.file_output_stream.FileOutputStream createFinish(gio.async_result.AsyncResult res)

Finishes an asynchronous file create operation started with gio.file.File.createAsync.

createReadwrite
gio.file_iostream.FileIOStream createReadwrite(gio.types.FileCreateFlags flags, gio.cancellable.Cancellable cancellable)

Creates a new file and returns a stream for reading and writing to it. The file must not already exist.

createReadwriteAsync
void createReadwriteAsync(gio.types.FileCreateFlags flags, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously creates a new file and returns a stream for reading and writing to it. The file must not already exist.

createReadwriteFinish
gio.file_iostream.FileIOStream createReadwriteFinish(gio.async_result.AsyncResult res)

Finishes an asynchronous file create operation started with gio.file.File.createReadwriteAsync.

deleteAsync
void deleteAsync(int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously delete a file. If the file is a directory, it will only be deleted if it is empty. This has the same semantics as glib.global.unlink.

deleteFinish
bool deleteFinish(gio.async_result.AsyncResult result)

Finishes deleting a file started with gio.file.File.deleteAsync.

delete_
bool delete_(gio.cancellable.Cancellable cancellable)

Deletes a file. If the file is a directory, it will only be deleted if it is empty. This has the same semantics as glib.global.unlink.

dup
gio.file.File dup()

Duplicates a #GFile handle. This operation does not duplicate the actual file or directory represented by the #GFile; see gio.file.File.copy if attempting to copy a file.

ejectMountable
void ejectMountable(gio.types.MountUnmountFlags flags, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

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 gio.file.File.ejectMountableFinish.

ejectMountableFinish
bool ejectMountableFinish(gio.async_result.AsyncResult result)

Finishes an asynchronous eject operation started by gio.file.File.ejectMountable.

ejectMountableWithOperation
void ejectMountableWithOperation(gio.types.MountUnmountFlags flags, gio.mount_operation.MountOperation mountOperation, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

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 gio.file.File.ejectMountableWithOperationFinish.

ejectMountableWithOperationFinish
bool ejectMountableWithOperationFinish(gio.async_result.AsyncResult result)

Finishes an asynchronous eject operation started by gio.file.File.ejectMountableWithOperation.

enumerateChildren
gio.file_enumerator.FileEnumerator enumerateChildren(string attributes, gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

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.

enumerateChildrenAsync
void enumerateChildrenAsync(string attributes, gio.types.FileQueryInfoFlags flags, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

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

enumerateChildrenFinish
gio.file_enumerator.FileEnumerator enumerateChildrenFinish(gio.async_result.AsyncResult res)

Finishes an async enumerate children operation. See gio.file.File.enumerateChildrenAsync.

equal
bool equal(gio.file.File file2)

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

findEnclosingMount
gio.mount.Mount findEnclosingMount(gio.cancellable.Cancellable cancellable)

Gets a #GMount for the #GFile.

findEnclosingMountAsync
void findEnclosingMountAsync(int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously gets the mount for the file.

findEnclosingMountFinish
gio.mount.Mount findEnclosingMountFinish(gio.async_result.AsyncResult res)

Finishes an asynchronous find mount request. See gio.file.File.findEnclosingMountAsync.

getBasename
string getBasename()

Gets the base name (the last component of the path) for a given #GFile.

getChild
gio.file.File getChild(string name)

Gets a child of file with basename equal to name.

getChildForDisplayName
gio.file.File getChildForDisplayName(string displayName)

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.

getParent
gio.file.File getParent()

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

getParseName
string getParseName()

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 gio.file.File.parseName.

getPath
string getPath()

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.

getRelativePath
string getRelativePath(gio.file.File descendant)

Gets the path for descendant relative to parent.

getUri
string getUri()

Gets the URI for the file.

getUriScheme
string getUriScheme()

Gets the URI scheme for a #GFile. RFC 3986 decodes the scheme as:

hasParent
bool hasParent(gio.file.File parent)

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

hasPrefix
bool hasPrefix(gio.file.File prefix)

Checks whether file has the prefix specified by prefix.

hasUriScheme
bool hasUriScheme(string uriScheme)

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

hash
uint hash()

Creates a hash value for a #GFile.

isNative
bool isNative()

Checks to see if a file is native to the platform.

loadBytes
glib.bytes.Bytes loadBytes(gio.cancellable.Cancellable cancellable, string etagOut)

Loads the contents of file and returns it as #GBytes.

loadBytesAsync
void loadBytesAsync(gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously loads the contents of file as #GBytes.

loadBytesFinish
glib.bytes.Bytes loadBytesFinish(gio.async_result.AsyncResult result, string etagOut)

Completes an asynchronous request to gio.file.File.loadBytesAsync.

loadContents
bool loadContents(gio.cancellable.Cancellable cancellable, ubyte[] contents, string etagOut)

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 contents should be freed with glib.global.gfree when no longer needed.

loadContentsAsync
void loadContentsAsync(gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Starts an asynchronous load of the file's contents.

loadContentsFinish
bool loadContentsFinish(gio.async_result.AsyncResult res, ubyte[] contents, string etagOut)

Finishes an asynchronous load of the file's contents. The contents are placed in contents, and length is set to the size of the contents string. The contents should be freed with glib.global.gfree when no longer needed. If etag_out is present, it will be set to the new entity tag for the file.

loadPartialContentsFinish
bool loadPartialContentsFinish(gio.async_result.AsyncResult res, ubyte[] contents, string etagOut)

Finishes an asynchronous partial load operation that was started with gio.file.File.loadPartialContentsAsync. The data is always zero-terminated, but this is not included in the resultant length. The returned contents should be freed with glib.global.gfree when no longer needed.

makeDirectory
bool makeDirectory(gio.cancellable.Cancellable cancellable)

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 gio.file.File.makeDirectoryWithParents. This function will fail if the parent directory does not exist, setting error to gio.types.IOErrorEnum.NotFound. If the file system doesn't support creating directories, this function will fail, setting error to gio.types.IOErrorEnum.NotSupported.

makeDirectoryAsync
void makeDirectoryAsync(int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously creates a directory.

makeDirectoryFinish
bool makeDirectoryFinish(gio.async_result.AsyncResult result)

Finishes an asynchronous directory creation, started with gio.file.File.makeDirectoryAsync.

makeDirectoryWithParents
bool makeDirectoryWithParents(gio.cancellable.Cancellable cancellable)

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 gio.types.IOErrorEnum.NotSupported. If the directory itself already exists, this function will fail setting error to gio.types.IOErrorEnum.Exists, unlike the similar glib.global.mkdirWithParents.

makeSymbolicLink
bool makeSymbolicLink(string symlinkValue, gio.cancellable.Cancellable cancellable)

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

makeSymbolicLinkAsync
void makeSymbolicLinkAsync(string symlinkValue, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously creates a symbolic link named file which contains the string symlink_value.

makeSymbolicLinkFinish
bool makeSymbolicLinkFinish(gio.async_result.AsyncResult result)

Finishes an asynchronous symbolic link creation, started with gio.file.File.makeSymbolicLinkAsync.

measureDiskUsage
bool measureDiskUsage(gio.types.FileMeasureFlags flags, gio.cancellable.Cancellable cancellable, gio.types.FileMeasureProgressCallback progressCallback, ulong diskUsage, ulong numDirs, ulong numFiles)

Recursively measures the disk usage of file.

measureDiskUsageFinish
bool measureDiskUsageFinish(gio.async_result.AsyncResult result, ulong diskUsage, ulong numDirs, ulong numFiles)

Collects the results from an earlier call to gio.file.File.measureDiskUsageAsync. See gio.file.File.measureDiskUsage for more information.

monitor
gio.file_monitor.FileMonitor monitor(gio.types.FileMonitorFlags flags, gio.cancellable.Cancellable cancellable)

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

monitorDirectory
gio.file_monitor.FileMonitor monitorDirectory(gio.types.FileMonitorFlags flags, gio.cancellable.Cancellable cancellable)

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

monitorFile
gio.file_monitor.FileMonitor monitorFile(gio.types.FileMonitorFlags flags, gio.cancellable.Cancellable cancellable)

Obtains a file monitor for the given file. If no file notification mechanism exists, then regular polling of the file is used.

mountEnclosingVolume
void mountEnclosingVolume(gio.types.MountMountFlags flags, gio.mount_operation.MountOperation mountOperation, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Starts a mount_operation, mounting the volume that contains the file location.

mountEnclosingVolumeFinish
bool mountEnclosingVolumeFinish(gio.async_result.AsyncResult result)

Finishes a mount operation started by gio.file.File.mountEnclosingVolume.

mountMountable
void mountMountable(gio.types.MountMountFlags flags, gio.mount_operation.MountOperation mountOperation, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Mounts a file of type G_FILE_TYPE_MOUNTABLE. Using mount_operation, you can request callbacks when, for instance, passwords are needed during authentication.

mountMountableFinish
gio.file.File mountMountableFinish(gio.async_result.AsyncResult result)

Finishes a mount operation. See gio.file.File.mountMountable for details.

move
bool move(gio.file.File destination, gio.types.FileCopyFlags flags, gio.cancellable.Cancellable cancellable, gio.types.FileProgressCallback progressCallback)

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.

moveAsync
void moveAsync(gio.file.File destination, gio.types.FileCopyFlags flags, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.FileProgressCallback progressCallback, gio.types.AsyncReadyCallback callback)

Asynchronously moves a file source to the location of destination. For details of the behaviour, see gio.file.File.move.

moveFinish
bool moveFinish(gio.async_result.AsyncResult result)

Finishes an asynchronous file movement, started with gio.file.File.moveAsync.

openReadwrite
gio.file_iostream.FileIOStream openReadwrite(gio.cancellable.Cancellable cancellable)

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.

openReadwriteAsync
void openReadwriteAsync(int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously opens file for reading and writing.

openReadwriteFinish
gio.file_iostream.FileIOStream openReadwriteFinish(gio.async_result.AsyncResult res)

Finishes an asynchronous file read operation started with gio.file.File.openReadwriteAsync.

peekPath
string peekPath()

Exactly like gio.file.File.getPath, but caches the result via gobject.object.ObjectG.setQdataFull. 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.

pollMountable
void pollMountable(gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Polls a file of type gio.types.FileType.Mountable.

pollMountableFinish
bool pollMountableFinish(gio.async_result.AsyncResult result)

Finishes a poll operation. See gio.file.File.pollMountable for details.

queryDefaultHandler
gio.app_info.AppInfo queryDefaultHandler(gio.cancellable.Cancellable cancellable)

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

queryDefaultHandlerAsync
void queryDefaultHandlerAsync(int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Async version of gio.file.File.queryDefaultHandler.

queryDefaultHandlerFinish
gio.app_info.AppInfo queryDefaultHandlerFinish(gio.async_result.AsyncResult result)

Finishes a gio.file.File.queryDefaultHandlerAsync operation.

queryExists
bool queryExists(gio.cancellable.Cancellable cancellable)

Utility function to check if a particular file exists. This is implemented using gio.file.File.queryInfo and as such does blocking I/O.

queryFileType
gio.types.FileType queryFileType(gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

Utility function to inspect the #GFileType of a file. This is implemented using gio.file.File.queryInfo and as such does blocking I/O.

queryFilesystemInfo
gio.file_info.FileInfo queryFilesystemInfo(string attributes, gio.cancellable.Cancellable cancellable)

Similar to gio.file.File.queryInfo, 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.

queryFilesystemInfoAsync
void queryFilesystemInfoAsync(string attributes, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously gets the requested information about the filesystem that the specified file is on. The result is a #GFileInfo object that contains key-value attributes (such as type or size for the file).

queryFilesystemInfoFinish
gio.file_info.FileInfo queryFilesystemInfoFinish(gio.async_result.AsyncResult res)

Finishes an asynchronous filesystem info query. See gio.file.File.queryFilesystemInfoAsync.

queryInfo
gio.file_info.FileInfo queryInfo(string attributes, gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

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

queryInfoAsync
void queryInfoAsync(string attributes, gio.types.FileQueryInfoFlags flags, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously gets the requested information about specified file. The result is a #GFileInfo object that contains key-value attributes (such as type or size for the file).

queryInfoFinish
gio.file_info.FileInfo queryInfoFinish(gio.async_result.AsyncResult res)

Finishes an asynchronous file info query. See gio.file.File.queryInfoAsync.

querySettableAttributes
gio.file_attribute_info_list.FileAttributeInfoList querySettableAttributes(gio.cancellable.Cancellable cancellable)

Obtain the list of settable attributes for the file.

queryWritableNamespaces
gio.file_attribute_info_list.FileAttributeInfoList queryWritableNamespaces(gio.cancellable.Cancellable cancellable)

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

read
gio.file_input_stream.FileInputStream read(gio.cancellable.Cancellable cancellable)

Opens a file for reading. The result is a #GFileInputStream that can be used to read the contents of the file.

readAsync
void readAsync(int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously opens file for reading.

readFinish
gio.file_input_stream.FileInputStream readFinish(gio.async_result.AsyncResult res)

Finishes an asynchronous file read operation started with gio.file.File.readAsync.

replace
gio.file_output_stream.FileOutputStream replace(string etag, bool makeBackup, gio.types.FileCreateFlags flags, gio.cancellable.Cancellable cancellable)

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.

replaceAsync
void replaceAsync(string etag, bool makeBackup, gio.types.FileCreateFlags flags, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.

replaceContents
bool replaceContents(ubyte[] contents, string etag, bool makeBackup, gio.types.FileCreateFlags flags, string newEtag, gio.cancellable.Cancellable cancellable)

Replaces the contents of file with contents of length bytes.

replaceContentsAsync
void replaceContentsAsync(ubyte[] contents, string etag, bool makeBackup, gio.types.FileCreateFlags flags, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Starts an asynchronous replacement of file with the given contents of length bytes. etag will replace the document's current entity tag.

replaceContentsBytesAsync
void replaceContentsBytesAsync(glib.bytes.Bytes contents, string etag, bool makeBackup, gio.types.FileCreateFlags flags, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Same as gio.file.File.replaceContentsAsync but takes a #GBytes input instead. This function will keep a ref on contents until the operation is done. Unlike gio.file.File.replaceContentsAsync this allows forgetting about the content without waiting for the callback.

replaceContentsFinish
bool replaceContentsFinish(gio.async_result.AsyncResult res, string newEtag)

Finishes an asynchronous replace of the given file. See gio.file.File.replaceContentsAsync. Sets new_etag to the new entity tag for the document, if present.

replaceFinish
gio.file_output_stream.FileOutputStream replaceFinish(gio.async_result.AsyncResult res)

Finishes an asynchronous file replace operation started with gio.file.File.replaceAsync.

replaceReadwrite
gio.file_iostream.FileIOStream replaceReadwrite(string etag, bool makeBackup, gio.types.FileCreateFlags flags, gio.cancellable.Cancellable cancellable)

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.

replaceReadwriteAsync
void replaceReadwriteAsync(string etag, bool makeBackup, gio.types.FileCreateFlags flags, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.

replaceReadwriteFinish
gio.file_iostream.FileIOStream replaceReadwriteFinish(gio.async_result.AsyncResult res)

Finishes an asynchronous file replace operation started with gio.file.File.replaceReadwriteAsync.

resolveRelativePath
gio.file.File resolveRelativePath(string relativePath)

Resolves a relative path for file to an absolute path.

setAttribute
bool setAttribute(string attribute, gio.types.FileAttributeType type, void* valueP, gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

Sets an attribute in the file with attribute name attribute to value_p.

setAttributeByteString
bool setAttributeByteString(string attribute, string value, gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

Sets attribute of type gio.types.FileAttributeType.ByteString to value. If attribute is of a different type, this operation will fail, returning false.

setAttributeInt32
bool setAttributeInt32(string attribute, int value, gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

Sets attribute of type gio.types.FileAttributeType.Int32 to value. If attribute is of a different type, this operation will fail.

setAttributeInt64
bool setAttributeInt64(string attribute, long value, gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

Sets attribute of type gio.types.FileAttributeType.Int64 to value. If attribute is of a different type, this operation will fail.

setAttributeString
bool setAttributeString(string attribute, string value, gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

Sets attribute of type gio.types.FileAttributeType.String to value. If attribute is of a different type, this operation will fail.

setAttributeUint32
bool setAttributeUint32(string attribute, uint value, gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

Sets attribute of type gio.types.FileAttributeType.Uint32 to value. If attribute is of a different type, this operation will fail.

setAttributeUint64
bool setAttributeUint64(string attribute, ulong value, gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

Sets attribute of type gio.types.FileAttributeType.Uint64 to value. If attribute is of a different type, this operation will fail.

setAttributesAsync
void setAttributesAsync(gio.file_info.FileInfo info, gio.types.FileQueryInfoFlags flags, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously sets the attributes of file with info.

setAttributesFinish
bool setAttributesFinish(gio.async_result.AsyncResult result, gio.file_info.FileInfo info)

Finishes setting an attribute started in gio.file.File.setAttributesAsync.

setAttributesFromInfo
bool setAttributesFromInfo(gio.file_info.FileInfo info, gio.types.FileQueryInfoFlags flags, gio.cancellable.Cancellable cancellable)

Tries to set all attributes in the #GFileInfo on the target values, not stopping on the first error.

setDisplayName
gio.file.File setDisplayName(string displayName, gio.cancellable.Cancellable cancellable)

Renames file to the specified display name.

setDisplayNameAsync
void setDisplayNameAsync(string displayName, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously sets the display name for a given #GFile.

setDisplayNameFinish
gio.file.File setDisplayNameFinish(gio.async_result.AsyncResult res)

Finishes setting a display name started with gio.file.File.setDisplayNameAsync.

startMountable
void startMountable(gio.types.DriveStartFlags flags, gio.mount_operation.MountOperation startOperation, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Starts a file of type gio.types.FileType.Mountable. Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.

startMountableFinish
bool startMountableFinish(gio.async_result.AsyncResult result)

Finishes a start operation. See gio.file.File.startMountable for details.

stopMountable
void stopMountable(gio.types.MountUnmountFlags flags, gio.mount_operation.MountOperation mountOperation, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Stops a file of type gio.types.FileType.Mountable.

stopMountableFinish
bool stopMountableFinish(gio.async_result.AsyncResult result)

Finishes a stop operation, see gio.file.File.stopMountable for details.

supportsThreadContexts
bool supportsThreadContexts()

Checks if file supports [thread-default contexts][g-main-context-push-thread-default-context]. If this returns false, you cannot perform asynchronous operations on file in a thread that has a thread-default context.

trash
bool trash(gio.cancellable.Cancellable cancellable)

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 gio.types.IOErrorEnum.NotSupported error. Since GLib 2.66, the x-gvfs-notrash unix mount option can be used to disable gio.file.File.trash support for certain mounts, the gio.types.IOErrorEnum.NotSupported error will be returned in that case.

trashAsync
void trashAsync(int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously sends file to the Trash location, if possible.

trashFinish
bool trashFinish(gio.async_result.AsyncResult result)

Finishes an asynchronous file trashing operation, started with gio.file.File.trashAsync.

unmountMountable
void unmountMountable(gio.types.MountUnmountFlags flags, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Unmounts a file of type G_FILE_TYPE_MOUNTABLE.

unmountMountableFinish
bool unmountMountableFinish(gio.async_result.AsyncResult result)

Finishes an unmount operation, see gio.file.File.unmountMountable for details.

unmountMountableWithOperation
void unmountMountableWithOperation(gio.types.MountUnmountFlags flags, gio.mount_operation.MountOperation mountOperation, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Unmounts a file of type gio.types.FileType.Mountable.

unmountMountableWithOperationFinish
bool unmountMountableWithOperationFinish(gio.async_result.AsyncResult result)

Finishes an unmount operation, see gio.file.File.unmountMountableWithOperation for details.

Static functions

newBuildFilenamev
gio.file.File newBuildFilenamev(string[] args)

Constructs a #GFile from a vector of elements using the correct separator for filenames.

newForCommandlineArg
gio.file.File newForCommandlineArg(string arg)

Creates a #GFile with the given argument from the command line. The value of arg can be either a URI, an absolute path or a relative path resolved relative to the current working directory. This operation never fails, but the returned object might not support any I/O operation if arg points to a malformed path.

newForCommandlineArgAndCwd
gio.file.File newForCommandlineArgAndCwd(string arg, string cwd)

Creates a #GFile with the given argument from the command line.

newForPath
gio.file.File newForPath(string path)

Constructs a #GFile for a given path. This operation never fails, but the returned object might not support any I/O operation if path is malformed.

newForUri
gio.file.File newForUri(string uri)

Constructs a #GFile for a given URI. This operation never fails, but the returned object might not support any I/O operation if uri is malformed or if the uri type is not supported.

newTmp
gio.file.File newTmp(string tmpl, gio.file_iostream.FileIOStream iostream)

Opens a file in the preferred directory for temporary files (as returned by glib.global.getTmpDir) and returns a #GFile and #GFileIOStream pointing to it.

newTmpAsync
void newTmpAsync(string tmpl, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously opens a file in the preferred directory for temporary files (as returned by glib.global.getTmpDir) as gio.file.File.newTmp.

newTmpDirAsync
void newTmpDirAsync(string tmpl, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously creates a directory in the preferred directory for temporary files (as returned by glib.global.getTmpDir) as glib.dir.Dir.makeTmp.

newTmpDirFinish
gio.file.File newTmpDirFinish(gio.async_result.AsyncResult result)

Finishes a temporary directory creation started by gio.file.File.newTmpDirAsync.

newTmpFinish
gio.file.File newTmpFinish(gio.async_result.AsyncResult result, gio.file_iostream.FileIOStream iostream)

Finishes a temporary file creation started by gio.file.File.newTmpAsync.

parseName
gio.file.File parseName(string parseName)

Constructs a #GFile with the given parse_name (i.e. something given by gio.file.File.getParseName). This operation never fails, but the returned object might not support any I/O operation if the parse_name cannot be parsed.