gi-gio-2.0.25: Gio bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Interfaces.File

Contents

Description

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

To construct a File, you can use:

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

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

All GFiles have a basename (get with fileGetBasename). 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 FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with fileQueryInfo. This is guaranteed to be in UTF-8 and can be used in a user interface. But always store the real basename or the File to use to actually access the file, because there is no way to go from a display name to the actual name.

Using 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 GFiles 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 GFiles point to the same file you can query for the FILE_ATTRIBUTE_ID_FILE attribute. Note that 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 GFiles.

Many 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 AsyncReadyCallback which is then used to finalize the operation, producing a GAsyncResult 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][async-programming] for more.

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

# {gfile-etag}

One notable feature of GFiles 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.

Synopsis

Exported types

newtype File Source #

Memory-managed wrapper type.

Constructors

File (ManagedPtr File) 

Instances

Instances details
Eq File Source # 
Instance details

Defined in GI.Gio.Interfaces.File

Methods

(==) :: File -> File -> Bool #

(/=) :: File -> File -> Bool #

GObject File Source # 
Instance details

Defined in GI.Gio.Interfaces.File

Methods

gobjectType :: IO GType #

IsGValue File Source #

Convert File to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Gio.Interfaces.File

HasParentTypes File Source # 
Instance details

Defined in GI.Gio.Interfaces.File

type ParentTypes File Source # 
Instance details

Defined in GI.Gio.Interfaces.File

noFile :: Maybe File Source #

A convenience alias for Nothing :: Maybe File.

class (GObject o, IsDescendantOf File o) => IsFile o Source #

Type class for types which can be safely cast to File, for instance with toFile.

Instances

Instances details
(GObject o, IsDescendantOf File o) => IsFile o Source # 
Instance details

Defined in GI.Gio.Interfaces.File

toFile :: (MonadIO m, IsFile o) => o -> m File Source #

Cast to File, for types for which this is known to be safe. For general casts, use castTo.

Methods

Overloaded methods

appendTo

fileAppendTo Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileOutputStream

Returns: a FileOutputStream, or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

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

appendToAsync

fileAppendToAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Asynchronously opens file for appending.

For more details, see fileAppendTo which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileAppendToFinish to get the result of the operation.

appendToFinish

fileAppendToFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: AsyncResult

-> m FileOutputStream

Returns: a valid FileOutputStream or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes an asynchronous file append operation started with fileAppendToAsync.

copy

fileCopy Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsFile b, IsCancellable c) 
=> a

source: input File

-> b

destination: destination File

-> [FileCopyFlags]

flags: set of FileCopyFlags

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe FileProgressCallback

progressCallback: function to callback with progress information, or Nothing if progress information is not needed

-> m ()

(Can throw GError)

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

If the flag G_FILE_COPY_OVERWRITE is specified an already existing destination file is overwritten.

If the flag G_FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.

If the flag G_FILE_COPY_ALL_METADATA is specified then all the metadata that is possible to copy is copied, not just the default subset (which, for instance, does not include the owner, see FileInfo).

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

If progressCallback is not Nothing, then the operation can be monitored by setting this to a FileProgressCallback function. progressCallbackData will be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation.

If the source file does not exist, then the IOErrorEnumNotFound error is returned, independent on the status of the destination.

If G_FILE_COPY_OVERWRITE is not specified and the target exists, then the error IOErrorEnumExists is returned.

If trying to overwrite a file over a directory, the IOErrorEnumIsDirectory error is returned. If trying to overwrite a directory with a directory the IOErrorEnumWouldMerge error is returned.

If the source is a directory and the target does not exist, or G_FILE_COPY_OVERWRITE is specified and the target is a file, then the IOErrorEnumWouldRecurse error is returned.

If you are interested in copying the File object itself (not the on-disk file), see fileDup.

copyAttributes

fileCopyAttributes Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsFile b, IsCancellable c) 
=> a

source: a File with attributes

-> b

destination: a File to copy attributes to

-> [FileCopyFlags]

flags: a set of FileCopyFlags

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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.

copyFinish

fileCopyFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m ()

(Can throw GError)

Finishes copying the file started with fileCopyAsync.

create

fileCreate Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileOutputStream

Returns: a FileOutputStream for the newly created file, or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

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

createAsync

fileCreateAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

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

For more details, see fileCreate which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileCreateFinish to get the result of the operation.

createFinish

fileCreateFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m FileOutputStream

Returns: a FileOutputStream or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes an asynchronous file create operation started with fileCreateAsync.

createReadwrite

fileCreateReadwrite Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: a File

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileIOStream

Returns: a FileIOStream for the newly created file, or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

If a file or directory with this name already exists, the IOErrorEnumExists error will be returned. Some file systems don't allow all file names, and may return an IOErrorEnumInvalidFilename error, and if the name is too long, IOErrorEnumFilenameTooLong 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.

Since: 2.22

createReadwriteAsync

fileCreateReadwriteAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

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

For more details, see fileCreateReadwrite which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileCreateReadwriteFinish to get the result of the operation.

Since: 2.22

createReadwriteFinish

fileCreateReadwriteFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m FileIOStream

Returns: a FileIOStream or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes an asynchronous file create operation started with fileCreateReadwriteAsync.

Since: 2.22

delete

fileDelete Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

deleteAsync

fileDeleteAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

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

Since: 2.34

deleteFinish

fileDeleteFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes deleting a file started with fileDeleteAsync.

Since: 2.34

dup

fileDup Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> m File

Returns: a new File that is a duplicate of the given File.

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

fileDup is useful when a second handle is needed to the same underlying file, for use in a separate thread (tFile is not thread-safe). For use within the same thread, use objectRef to increment the existing object’s reference count.

This call does no blocking I/O.

ejectMountable

fileEjectMountable Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [MountUnmountFlags]

flags: flags affecting the operation

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied, or Nothing

-> m () 

Deprecated: (Since version 2.22)Use fileEjectMountableWithOperation instead.

Starts an asynchronous eject on a mountable. When this operation has completed, callback will be called with userUser data, and the operation can be finalized with fileEjectMountableFinish.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

ejectMountableFinish

fileEjectMountableFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Deprecated: (Since version 2.22)Use fileEjectMountableWithOperationFinish instead.

Finishes an asynchronous eject operation started by fileEjectMountable.

ejectMountableWithOperation

fileEjectMountableWithOperation Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) 
=> a

file: input File

-> [MountUnmountFlags]

flags: flags affecting the operation

-> Maybe b

mountOperation: a MountOperation, or Nothing to avoid user interaction

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied, or Nothing

-> m () 

Starts an asynchronous eject on a mountable. When this operation has completed, callback will be called with userUser data, and the operation can be finalized with fileEjectMountableWithOperationFinish.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

Since: 2.22

ejectMountableWithOperationFinish

fileEjectMountableWithOperationFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes an asynchronous eject operation started by fileEjectMountableWithOperation.

Since: 2.22

enumerateChildren

fileEnumerateChildren Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attributes: an attribute query string

-> [FileQueryInfoFlags]

flags: a set of FileQueryInfoFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileEnumerator

Returns: A FileEnumerator if successful, Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Gets the requested information about the files in a directory. The result is a FileEnumerator object that will give out FileInfo objects for all the files in the directory.

The attributes value is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. attributes should be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*" means all attributes in the standard namespace. An example attribute query be "standard::*,owner[user](#signal:user)". The standard attributes are available as defines, like FILE_ATTRIBUTE_STANDARD_NAME.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

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

enumerateChildrenAsync

fileEnumerateChildrenAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attributes: an attribute query string

-> [FileQueryInfoFlags]

flags: a set of FileQueryInfoFlags

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

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.

For more details, see fileEnumerateChildren which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileEnumerateChildrenFinish to get the result of the operation.

enumerateChildrenFinish

fileEnumerateChildrenFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m FileEnumerator

Returns: a FileEnumerator or Nothing if an error occurred. Free the returned object with objectUnref. (Can throw GError)

Finishes an async enumerate children operation. See fileEnumerateChildrenAsync.

equal

fileEqual Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsFile b) 
=> a

file1: the first File

-> b

file2: the second File

-> m Bool

Returns: True if file1 and file2 are equal.

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.

findEnclosingMount

fileFindEnclosingMount Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m Mount

Returns: a Mount where the file is located or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Gets a Mount for the File.

If the FileIface for file does not have a mount (e.g. possibly a remote share), error will be set to IOErrorEnumNotFound and Nothing will be returned.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

findEnclosingMountAsync

fileFindEnclosingMountAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: a File

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Asynchronously gets the mount for the file.

For more details, see fileFindEnclosingMount which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileFindEnclosingMountFinish to get the result of the operation.

findEnclosingMountFinish

fileFindEnclosingMountFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: a File

-> b

res: a AsyncResult

-> m Mount

Returns: Mount for given file or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes an asynchronous find mount request. See fileFindEnclosingMountAsync.

getBasename

fileGetBasename Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> m (Maybe [Char])

Returns: string containing the File's base name, or Nothing if given File is invalid. The returned string should be freed with free when no longer needed.

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

If called for the top level of a system (such as the filesystem root or a uri like sftp://host/) it will return a single directory separator (and on Windows, possibly a drive letter).

The base name is a byte string (not UTF-8). It has no defined encoding or rules other than it may not contain zero bytes. If you want to use filenames in a user interface you should use the display name that you can get by requesting the FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with fileQueryInfo.

This call does no blocking I/O.

getChild

fileGetChild Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> [Char]

name: string containing the child's basename

-> m File

Returns: a File to a child specified by name. Free the returned object with objectUnref.

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 File that points to it. You can use this for instance to create that file.

This call does no blocking I/O.

getChildForDisplayName

fileGetChildForDisplayName Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> Text

displayName: string to a possible child

-> m File

Returns: a File to the specified child, or Nothing if the display name couldn't be converted. Free the returned object with objectUnref. (Can throw GError)

Gets the child of file for a given displayName (i.e. a UTF-8 version of the name). If this function fails, it returns Nothing and error will be set. This is very useful when constructing a File 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.

getParent

fileGetParent Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> m (Maybe File)

Returns: a File structure to the parent of the given File or Nothing if there is no parent. Free the returned object with objectUnref.

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

This call does no blocking I/O.

getParseName

fileGetParseName Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> m Text

Returns: a string containing the File's parse name. The returned string should be freed with free when no longer needed.

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

This is generally used to show the File 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.

getPath

fileGetPath Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> m (Maybe [Char])

Returns: string containing the File's path, or Nothing if no such path exists. The returned string should be freed with free when no longer needed.

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

This call does no blocking I/O.

getRelativePath

fileGetRelativePath Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsFile b) 
=> a

parent: input File

-> b

descendant: input File

-> m (Maybe [Char])

Returns: string with the relative path from descendant to parent, or Nothing if descendant doesn't have parent as prefix. The returned string should be freed with free when no longer needed.

Gets the path for descendant relative to parent.

This call does no blocking I/O.

getUri

fileGetUri Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> m Text

Returns: a string containing the File's URI. The returned string should be freed with free when no longer needed.

Gets the URI for the file.

This call does no blocking I/O.

getUriScheme

fileGetUriScheme Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> m Text

Returns: a string containing the URI scheme for the given File. The returned string should be freed with free when no longer needed.

Gets the URI scheme for a File. RFC 3986 decodes the scheme as: > >URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

Common schemes include "file", "http", "ftp", etc.

This call does no blocking I/O.

hasParent

fileHasParent Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsFile b) 
=> a

file: input File

-> Maybe b

parent: the parent to check for, or Nothing

-> m Bool

Returns: True if file is an immediate child of parent (or any parent in the case that parent is Nothing).

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

If parent is Nothing then this function returns True if file has any parent at all. If parent is non-Nothing then True is only returned if file is an immediate child of parent.

Since: 2.24

hasPrefix

fileHasPrefix Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsFile b) 
=> a

file: input File

-> b

prefix: input File

-> m Bool

Returns: True if the files's parent, grandparent, etc is prefix, False otherwise.

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 File is not a prefix of itself. If you want to check for equality, use fileEqual.

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.

hasUriScheme

fileHasUriScheme Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> Text

uriScheme: a string containing a URI scheme

-> m Bool

Returns: True if File's backend supports the given URI scheme, False if URI scheme is Nothing, not supported, or File is invalid.

Checks to see if a File has a given URI scheme.

This call does no blocking I/O.

hash

fileHash Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: gconstpointer to a File

-> m Word32

Returns: 0 if file is not a valid File, otherwise an integer that can be used as hash value for the File. This function is intended for easily hashing a File to add to a HashTable or similar data structure.

Creates a hash value for a File.

This call does no blocking I/O.

isNative

fileIsNative Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> m Bool

Returns: True if file is native

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 fileGetPath will still return a native path.

This call does no blocking I/O.

loadBytes

fileLoadBytes Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: a File

-> Maybe b

cancellable: a Cancellable or Nothing

-> m (Bytes, Maybe Text)

Returns: a Bytes or Nothing and error is set (Can throw GError)

Loads the contents of file and returns it as Bytes.

If file is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling fileLoadContents and bytesNewTake.

For resources, etagOut will be set to Nothing.

The data contained in the resulting Bytes is always zero-terminated, but this is not included in the Bytes length. The resulting Bytes should be freed with bytesUnref when no longer in use.

Since: 2.56

loadBytesAsync

fileLoadBytesAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: a File

-> Maybe b

cancellable: a Cancellable or Nothing

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Asynchronously loads the contents of file as Bytes.

If file is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling fileLoadContentsAsync and bytesNewTake.

callback should call fileLoadBytesFinish to get the result of this asynchronous operation.

See fileLoadBytes for more information.

Since: 2.56

loadBytesFinish

fileLoadBytesFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: a File

-> b

result: a AsyncResult provided to the callback

-> m (Bytes, Maybe Text)

Returns: a Bytes or Nothing and error is set (Can throw GError)

Completes an asynchronous request to fileLoadBytesAsync.

For resources, etagOut will be set to Nothing.

The data contained in the resulting Bytes is always zero-terminated, but this is not included in the Bytes length. The resulting Bytes should be freed with bytesUnref when no longer in use.

See fileLoadBytes for more information.

Since: 2.56

loadContents

fileLoadContents Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m (ByteString, Text)

(Can throw GError)

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 free when no longer needed.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

loadContentsAsync

fileLoadContentsAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Starts an asynchronous load of the file's contents.

For more details, see fileLoadContents which is the synchronous version of this call.

When the load operation has completed, callback will be called with user data. To finish the operation, call fileLoadContentsFinish with the AsyncResult returned by the callback.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

loadContentsFinish

fileLoadContentsFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m (ByteString, Text)

(Can throw GError)

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 content should be freed with free when no longer needed. If etagOut is present, it will be set to the new entity tag for the file.

loadPartialContentsFinish

fileLoadPartialContentsFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m (ByteString, Text)

(Can throw GError)

Finishes an asynchronous partial load operation that was started with g_file_load_partial_contents_async(). The data is always zero-terminated, but this is not included in the resultant length. The returned content should be freed with free when no longer needed.

makeDirectory

fileMakeDirectory Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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 fileMakeDirectoryWithParents. This function will fail if the parent directory does not exist, setting error to IOErrorEnumNotFound. If the file system doesn't support creating directories, this function will fail, setting error to IOErrorEnumNotSupported.

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

makeDirectoryAsync

fileMakeDirectoryAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Asynchronously creates a directory.

Since: 2.38

makeDirectoryFinish

fileMakeDirectoryFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes an asynchronous directory creation, started with fileMakeDirectoryAsync.

Since: 2.38

makeDirectoryWithParents

fileMakeDirectoryWithParents Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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 IOErrorEnumNotSupported. If the directory itself already exists, this function will fail setting error to IOErrorEnumExists, unlike the similar mkdirWithParents.

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

Since: 2.18

makeSymbolicLink

fileMakeSymbolicLink Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: a File with the name of the symlink to create

-> [Char]

symlinkValue: a string with the path for the target of the new symlink

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

measureDiskUsageFinish

fileMeasureDiskUsageFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: a File

-> b

result: the AsyncResult passed to your AsyncReadyCallback

-> m (Word64, Word64, Word64)

(Can throw GError)

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

Since: 2.38

monitor

fileMonitor Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [FileMonitorFlags]

flags: a set of FileMonitorFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileMonitor

Returns: a FileMonitor for the given file, or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

Since: 2.18

monitorDirectory

fileMonitorDirectory Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [FileMonitorFlags]

flags: a set of FileMonitorFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileMonitor

Returns: a FileMonitor for the given file, or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

It does not make sense for flags to contain FileMonitorFlagsWatchHardLinks, 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 fileMonitor.

monitorFile

fileMonitorFile Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [FileMonitorFlags]

flags: a set of FileMonitorFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileMonitor

Returns: a FileMonitor for the given file, or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

If flags contains FileMonitorFlagsWatchHardLinks 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 FileMonitor backend and/or filesystem type.

mountEnclosingVolume

fileMountEnclosingVolume Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) 
=> a

location: input File

-> [MountMountFlags]

flags: flags affecting the operation

-> Maybe b

mountOperation: a MountOperation or Nothing to avoid user interaction

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied, or Nothing

-> m () 

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

When this operation has completed, callback will be called with userUser data, and the operation can be finalized with fileMountEnclosingVolumeFinish.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

mountEnclosingVolumeFinish

fileMountEnclosingVolumeFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

location: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes a mount operation started by fileMountEnclosingVolume.

mountMountable

fileMountMountable Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) 
=> a

file: input File

-> [MountMountFlags]

flags: flags affecting the operation

-> Maybe b

mountOperation: a MountOperation, or Nothing to avoid user interaction

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied, or Nothing

-> m () 

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

When the operation is finished, callback will be called. You can then call fileMountMountableFinish to get the result of the operation.

mountMountableFinish

fileMountMountableFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m File

Returns: a File or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes a mount operation. See fileMountMountable for details.

Finish an asynchronous mount operation that was started with fileMountMountable.

move

fileMove Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsFile b, IsCancellable c) 
=> a

source: File pointing to the source location

-> b

destination: File pointing to the destination location

-> [FileCopyFlags]

flags: set of FileCopyFlags

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe FileProgressCallback

progressCallback: FileProgressCallback function for updates

-> m ()

(Can throw GError)

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.

If the flag G_FILE_COPY_OVERWRITE is specified an already existing destination file is overwritten.

If the flag G_FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

If progressCallback is not Nothing, then the operation can be monitored by setting this to a FileProgressCallback function. progressCallbackData will be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation.

If the source file does not exist, then the IOErrorEnumNotFound error is returned, independent on the status of the destination.

If G_FILE_COPY_OVERWRITE is not specified and the target exists, then the error IOErrorEnumExists is returned.

If trying to overwrite a file over a directory, the IOErrorEnumIsDirectory error is returned. If trying to overwrite a directory with a directory the IOErrorEnumWouldMerge error is returned.

If the source is a directory and the target does not exist, or G_FILE_COPY_OVERWRITE is specified and the target is a file, then the IOErrorEnumWouldRecurse error may be returned (if the native move operation isn't available).

newForCommandlineArg

fileNewForCommandlineArg Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> [Char]

arg: a command line string

-> m File

Returns: a new File. Free the returned object with objectUnref.

Creates a File 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.

Note that on Windows, this function expects its argument to be in UTF-8 -- not the system code page. This means that you should not use this function with string from argv as it is passed to main(). g_win32_get_command_line() will return a UTF-8 version of the commandline. Application also uses UTF-8 but applicationCommandLineCreateFileForArg may be more useful for you there. It is also always possible to use this function with OptionContext arguments of type OptionArgFilename.

newForCommandlineArgAndCwd

fileNewForCommandlineArgAndCwd Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> [Char]

arg: a command line string

-> [Char]

cwd: the current working directory of the commandline

-> m File

Returns: a new File

Creates a File with the given argument from the command line.

This function is similar to fileNewForCommandlineArg except that it allows for passing the current working directory as an argument instead of using the current working directory of the process.

This is useful if the commandline argument was given in a context other than the invocation of the current process.

See also applicationCommandLineCreateFileForArg.

Since: 2.36

newForPath

fileNewForPath Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> [Char]

path: a string containing a relative or absolute path. The string must be encoded in the glib filename encoding.

-> m File

Returns: a new File for the given path. Free the returned object with objectUnref.

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

newForUri

fileNewForUri Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

uri: a UTF-8 string containing a URI

-> m File

Returns: a new File for the given uri. Free the returned object with objectUnref.

Constructs a File 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

fileNewTmp Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Maybe [Char]

tmpl: Template for the file name, as in fileOpenTmp, or Nothing for a default template

-> m (File, FileIOStream)

Returns: a new File. Free the returned object with objectUnref. (Can throw GError)

Opens a file in the preferred directory for temporary files (as returned by getTmpDir) and returns a File and FileIOStream pointing to it.

tmpl should be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it is Nothing, a default template is used.

Unlike the other File constructors, this will return Nothing if a temporary file could not be created.

Since: 2.32

openReadwrite

fileOpenReadwrite Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: File to open

-> Maybe b

cancellable: a Cancellable

-> m FileIOStream

Returns: FileIOStream or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

If the file does not exist, the IOErrorEnumNotFound error will be returned. If the file is a directory, the IOErrorEnumIsDirectory 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.

Since: 2.22

openReadwriteAsync

fileOpenReadwriteAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Asynchronously opens file for reading and writing.

For more details, see fileOpenReadwrite which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileOpenReadwriteFinish to get the result of the operation.

Since: 2.22

openReadwriteFinish

fileOpenReadwriteFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m FileIOStream

Returns: a FileIOStream or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes an asynchronous file read operation started with fileOpenReadwriteAsync.

Since: 2.22

parseName

fileParseName Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

parseName: a file name or path to be parsed

-> m File

Returns: a new File.

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

peekPath

filePeekPath Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> m (Maybe [Char])

Returns: string containing the File's path, or Nothing if no such path exists. The returned string is owned by file.

Exactly like fileGetPath, 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.

Since: 2.56

pollMountable

filePollMountable Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied, or Nothing

-> m () 

Polls a file of type G_FILE_TYPE_MOUNTABLE.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

When the operation is finished, callback will be called. You can then call fileMountMountableFinish to get the result of the operation.

Since: 2.22

pollMountableFinish

filePollMountableFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes a poll operation. See filePollMountable for details.

Finish an asynchronous poll operation that was polled with filePollMountable.

Since: 2.22

queryDefaultHandler

fileQueryDefaultHandler Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: a File to open

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m AppInfo

Returns: a AppInfo if the handle was found, Nothing if there were errors. When you are done with it, release it with objectUnref (Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

queryDefaultHandlerAsync

fileQueryDefaultHandlerAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: a File to open

-> Int32 
-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is done

-> m () 

Async version of fileQueryDefaultHandler.

Since: 2.60

queryDefaultHandlerFinish

fileQueryDefaultHandlerFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: a File to open

-> b

result: a AsyncResult

-> m AppInfo

Returns: a AppInfo if the handle was found, Nothing if there were errors. When you are done with it, release it with objectUnref (Can throw GError)

Finishes a fileQueryDefaultHandlerAsync operation.

Since: 2.60

queryExists

fileQueryExists Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m Bool

Returns: True if the file exists (and can be detected without error), False otherwise (or if cancelled).

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

Note that in many cases it is racy to first check for file existence and then execute something based on the outcome of that, because the file might have been created or removed in between the operations. The general approach to handling that is to not check, but just do the operation and handle the errors as they come.

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

queryFileType

fileQueryFileType Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [FileQueryInfoFlags]

flags: a set of FileQueryInfoFlags passed to fileQueryInfo

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileType

Returns: The FileType of the file and G_FILE_TYPE_UNKNOWN if the file does not exist

Utility function to inspect the FileType of a file. This is implemented using fileQueryInfo 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.

Since: 2.18

queryFilesystemInfo

fileQueryFilesystemInfo Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attributes: an attribute query string

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileInfo

Returns: a FileInfo or Nothing if there was an error. Free the returned object with objectUnref. (Can throw GError)

Similar to fileQueryInfo, 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 FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem in bytes), FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes available), and FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem).

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

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

queryFilesystemInfoAsync

fileQueryFilesystemInfoAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attributes: an attribute query string

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

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

For more details, see fileQueryFilesystemInfo which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileQueryInfoFinish to get the result of the operation.

queryFilesystemInfoFinish

fileQueryFilesystemInfoFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m FileInfo

Returns: FileInfo for given file or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes an asynchronous filesystem info query. See fileQueryFilesystemInfoAsync.

queryInfo

fileQueryInfo Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attributes: an attribute query string

-> [FileQueryInfoFlags]

flags: a set of FileQueryInfoFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileInfo

Returns: a FileInfo for the given file, or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

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](#signal:user)". The standard attributes are available as defines, like FILE_ATTRIBUTE_STANDARD_NAME.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled 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 IOErrorEnumNotFound error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

queryInfoAsync

fileQueryInfoAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attributes: an attribute query string

-> [FileQueryInfoFlags]

flags: a set of FileQueryInfoFlags

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

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

For more details, see fileQueryInfo which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileQueryInfoFinish to get the result of the operation.

queryInfoFinish

fileQueryInfoFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m FileInfo

Returns: FileInfo for given file or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes an asynchronous file info query. See fileQueryInfoAsync.

querySettableAttributes

fileQuerySettableAttributes Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileAttributeInfoList

Returns: a FileAttributeInfoList describing the settable attributes. When you are done with it, release it with fileAttributeInfoListUnref (Can throw GError)

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

queryWritableNamespaces

fileQueryWritableNamespaces Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileAttributeInfoList

Returns: a FileAttributeInfoList describing the writable namespaces. When you are done with it, release it with fileAttributeInfoListUnref (Can throw GError)

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

read

fileRead Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: File to read

-> Maybe b

cancellable: a Cancellable

-> m FileInputStream

Returns: FileInputStream or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

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

readAsync

fileReadAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Asynchronously opens file for reading.

For more details, see fileRead which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileReadFinish to get the result of the operation.

readFinish

fileReadFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m FileInputStream

Returns: a FileInputStream or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes an asynchronous file read operation started with fileReadAsync.

replace

fileReplace Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe Text

etag: an optional [entity tag][gfile-etag] for the current File, or NULL to ignore

-> Bool

makeBackup: True if a backup should be created

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileOutputStream

Returns: a FileOutputStream or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

If you pass in a non-Nothing etag value and file already exists, then this value is compared to the current entity tag of the file, and if they differ an IOErrorEnumWrongEtag error is returned. This generally means that the file has been changed since you last read it. You can get the new etag from fileOutputStreamGetEtag after you've finished writing and closed the FileOutputStream. When you load a new file you can use fileInputStreamQueryInfo to get the etag of the file.

If makeBackup is True, this function will attempt to make a backup of the current file before overwriting it. If this fails a IOErrorEnumCantCreateBackup error will be returned. If you want to replace anyway, try again with makeBackup set to False.

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

replaceAsync

fileReplaceAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe Text

etag: an [entity tag][gfile-etag] for the current File, or Nothing to ignore

-> Bool

makeBackup: True if a backup should be created

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

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

For more details, see fileReplace which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileReplaceFinish to get the result of the operation.

replaceContents

fileReplaceContents Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> ByteString

contents: a string containing the new contents for file

-> Maybe Text

etag: the old [entity-tag][gfile-etag] for the document, or Nothing

-> Bool

makeBackup: True if a backup should be created

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m Text

(Can throw GError)

Replaces the contents of file with contents of length bytes.

If etag is specified (not Nothing), any existing file must have that etag, or the error IOErrorEnumWrongEtag will be returned.

If makeBackup is True, this function will attempt to make a backup of file. Internally, it uses fileReplace, so will try to replace the file contents in the safest way possible. For example, atomic renames are used when replacing local files’ contents.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

The returned newEtag can be used to verify that the file hasn't changed the next time it is saved over.

replaceContentsAsync

fileReplaceContentsAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> ByteString

contents: string of contents to replace the file with

-> Maybe Text

etag: a new [entity tag][gfile-etag] for the file, or Nothing

-> Bool

makeBackup: True if a backup should be created

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

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

When this operation has completed, callback will be called with userUser data, and the operation can be finalized with fileReplaceContentsFinish.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

If makeBackup is True, this function will attempt to make a backup of file.

Note that no copy of content will be made, so it must stay valid until callback is called. See fileReplaceContentsBytesAsync for a Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.

replaceContentsBytesAsync

fileReplaceContentsBytesAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Bytes

contents: a Bytes

-> Maybe Text

etag: a new [entity tag][gfile-etag] for the file, or Nothing

-> Bool

makeBackup: True if a backup should be created

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Same as fileReplaceContentsAsync but takes a Bytes input instead. This function will keep a ref on contents until the operation is done. Unlike fileReplaceContentsAsync this allows forgetting about the content without waiting for the callback.

When this operation has completed, callback will be called with userUser data, and the operation can be finalized with fileReplaceContentsFinish.

Since: 2.40

replaceContentsFinish

fileReplaceContentsFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m Text

(Can throw GError)

Finishes an asynchronous replace of the given file. See fileReplaceContentsAsync. Sets newEtag to the new entity tag for the document, if present.

replaceFinish

fileReplaceFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m FileOutputStream

Returns: a FileOutputStream, or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes an asynchronous file replace operation started with fileReplaceAsync.

replaceReadwrite

fileReplaceReadwrite Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: a File

-> Maybe Text

etag: an optional [entity tag][gfile-etag] for the current File, or NULL to ignore

-> Bool

makeBackup: True if a backup should be created

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m FileIOStream

Returns: a FileIOStream or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

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

Since: 2.22

replaceReadwriteAsync

fileReplaceReadwriteAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Maybe Text

etag: an [entity tag][gfile-etag] for the current File, or Nothing to ignore

-> Bool

makeBackup: True if a backup should be created

-> [FileCreateFlags]

flags: a set of FileCreateFlags

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

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

For more details, see fileReplaceReadwrite which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileReplaceReadwriteFinish to get the result of the operation.

Since: 2.22

replaceReadwriteFinish

fileReplaceReadwriteFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m FileIOStream

Returns: a FileIOStream, or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes an asynchronous file replace operation started with fileReplaceReadwriteAsync.

Since: 2.22

resolveRelativePath

fileResolveRelativePath Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: input File

-> [Char]

relativePath: a given relative path string

-> m File

Returns: File to the resolved path. Nothing if relativePath is Nothing or if file is invalid. Free the returned object with objectUnref.

Resolves a relative path for file to an absolute path.

This call does no blocking I/O.

setAttribute

fileSetAttribute Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attribute: a string containing the attribute's name

-> FileAttributeType

type: The type of the attribute

-> Ptr ()

valueP: a pointer to the value (or the pointer itself if the type is a pointer type)

-> [FileQueryInfoFlags]

flags: a set of FileQueryInfoFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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

Some attributes can be unset by setting type to FileAttributeTypeInvalid and valueP to Nothing.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

setAttributeByteString

fileSetAttributeByteString Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attribute: a string containing the attribute's name

-> Text

value: a string containing the attribute's new value

-> [FileQueryInfoFlags]

flags: a FileQueryInfoFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

Sets attribute of type FileAttributeTypeByteString to value. If attribute is of a different type, this operation will fail, returning False.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

setAttributeInt32

fileSetAttributeInt32 Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attribute: a string containing the attribute's name

-> Int32

value: a gint32 containing the attribute's new value

-> [FileQueryInfoFlags]

flags: a FileQueryInfoFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

setAttributeInt64

fileSetAttributeInt64 Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attribute: a string containing the attribute's name

-> Int64

value: a guint64 containing the attribute's new value

-> [FileQueryInfoFlags]

flags: a FileQueryInfoFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

setAttributeString

fileSetAttributeString Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attribute: a string containing the attribute's name

-> Text

value: a string containing the attribute's value

-> [FileQueryInfoFlags]

flags: FileQueryInfoFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

setAttributeUint32

fileSetAttributeUint32 Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attribute: a string containing the attribute's name

-> Word32

value: a guint32 containing the attribute's new value

-> [FileQueryInfoFlags]

flags: a FileQueryInfoFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

setAttributeUint64

fileSetAttributeUint64 Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

attribute: a string containing the attribute's name

-> Word64

value: a guint64 containing the attribute's new value

-> [FileQueryInfoFlags]

flags: a FileQueryInfoFlags

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

setAttributesAsync

fileSetAttributesAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsFileInfo b, IsCancellable c) 
=> a

file: input File

-> b

info: a FileInfo

-> [FileQueryInfoFlags]

flags: a FileQueryInfoFlags

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback

-> m () 

Asynchronously sets the attributes of file with info.

For more details, see fileSetAttributesFromInfo, which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileSetAttributesFinish to get the result of the operation.

setAttributesFinish

fileSetAttributesFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m FileInfo

(Can throw GError)

Finishes setting an attribute started in fileSetAttributesAsync.

setAttributesFromInfo

fileSetAttributesFromInfo Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsFileInfo b, IsCancellable c) 
=> a

file: input File

-> b

info: a FileInfo

-> [FileQueryInfoFlags]

flags: FileQueryInfoFlags

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

Tries to set all attributes in the FileInfo 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 FileAttributeStatusErrorSetting, which means you can also detect further errors.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

setDisplayName

fileSetDisplayName Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

displayName: a string

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m File

Returns: a File specifying what file was renamed to, or Nothing if there was an error. Free the returned object with objectUnref. (Can throw GError)

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 (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 fileSetDisplayName.

On success the resulting converted filename is returned.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

setDisplayNameAsync

fileSetDisplayNameAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Text

displayName: a string

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Asynchronously sets the display name for a given File.

For more details, see fileSetDisplayName which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call fileSetDisplayNameFinish to get the result of the operation.

setDisplayNameFinish

fileSetDisplayNameFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

res: a AsyncResult

-> m File

Returns: a File or Nothing on error. Free the returned object with objectUnref. (Can throw GError)

Finishes setting a display name started with fileSetDisplayNameAsync.

startMountable

fileStartMountable Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) 
=> a

file: input File

-> [DriveStartFlags]

flags: flags affecting the operation

-> Maybe b

startOperation: a MountOperation, or Nothing to avoid user interaction

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied, or Nothing

-> m () 

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

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

When the operation is finished, callback will be called. You can then call fileMountMountableFinish to get the result of the operation.

Since: 2.22

startMountableFinish

fileStartMountableFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes a start operation. See fileStartMountable for details.

Finish an asynchronous start operation that was started with fileStartMountable.

Since: 2.22

stopMountable

fileStopMountable Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) 
=> a

file: input File

-> [MountUnmountFlags]

flags: flags affecting the operation

-> Maybe b

mountOperation: a MountOperation, or Nothing to avoid user interaction.

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied, or Nothing

-> m () 

Stops a file of type G_FILE_TYPE_MOUNTABLE.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

When the operation is finished, callback will be called. You can then call fileStopMountableFinish to get the result of the operation.

Since: 2.22

stopMountableFinish

fileStopMountableFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes an stop operation, see fileStopMountable for details.

Finish an asynchronous stop operation that was started with fileStopMountable.

Since: 2.22

supportsThreadContexts

fileSupportsThreadContexts Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a) 
=> a

file: a File

-> m Bool

Returns: Whether or not file supports thread-default contexts.

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.

Since: 2.22

trash

fileTrash Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: File to send to trash

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m ()

(Can throw GError)

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 IOErrorEnumNotSupported error.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

trashAsync

fileTrashAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> Int32

ioPriority: the [I/O priority][io-priority] of the request

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Asynchronously sends file to the Trash location, if possible.

Since: 2.38

trashFinish

fileTrashFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes an asynchronous file trashing operation, started with fileTrashAsync.

Since: 2.38

unmountMountable

fileUnmountMountable Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) 
=> a

file: input File

-> [MountUnmountFlags]

flags: flags affecting the operation

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied, or Nothing

-> m () 

Deprecated: (Since version 2.22)Use fileUnmountMountableWithOperation instead.

Unmounts a file of type G_FILE_TYPE_MOUNTABLE.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

When the operation is finished, callback will be called. You can then call fileUnmountMountableFinish to get the result of the operation.

unmountMountableFinish

fileUnmountMountableFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Deprecated: (Since version 2.22)Use fileUnmountMountableWithOperationFinish instead.

Finishes an unmount operation, see fileUnmountMountable for details.

Finish an asynchronous unmount operation that was started with fileUnmountMountable.

unmountMountableWithOperation

fileUnmountMountableWithOperation Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) 
=> a

file: input File

-> [MountUnmountFlags]

flags: flags affecting the operation

-> Maybe b

mountOperation: a MountOperation, or Nothing to avoid user interaction

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied, or Nothing

-> m () 

Unmounts a file of type G_FILE_TYPE_MOUNTABLE.

If cancellable is not Nothing, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnumCancelled will be returned.

When the operation is finished, callback will be called. You can then call fileUnmountMountableFinish to get the result of the operation.

Since: 2.22

unmountMountableWithOperationFinish

fileUnmountMountableWithOperationFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) 
=> a

file: input File

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes an unmount operation, see fileUnmountMountableWithOperation for details.

Finish an asynchronous unmount operation that was started with fileUnmountMountableWithOperation.

Since: 2.22