Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- Overloaded methods
- appendTo
- appendToAsync
- appendToFinish
- copy
- copyAttributes
- copyFinish
- create
- createAsync
- createFinish
- createReadwrite
- createReadwriteAsync
- createReadwriteFinish
- delete
- deleteAsync
- deleteFinish
- dup
- ejectMountable
- ejectMountableFinish
- ejectMountableWithOperation
- ejectMountableWithOperationFinish
- enumerateChildren
- enumerateChildrenAsync
- enumerateChildrenFinish
- equal
- findEnclosingMount
- findEnclosingMountAsync
- findEnclosingMountFinish
- getBasename
- getChild
- getChildForDisplayName
- getParent
- getParseName
- getPath
- getRelativePath
- getUri
- getUriScheme
- hasParent
- hasPrefix
- hasUriScheme
- hash
- isNative
- loadBytes
- loadBytesAsync
- loadBytesFinish
- loadContents
- loadContentsAsync
- loadContentsFinish
- loadPartialContentsFinish
- makeDirectory
- makeDirectoryAsync
- makeDirectoryFinish
- makeDirectoryWithParents
- makeSymbolicLink
- measureDiskUsageFinish
- monitor
- monitorDirectory
- monitorFile
- mountEnclosingVolume
- mountEnclosingVolumeFinish
- mountMountable
- mountMountableFinish
- move
- newForCommandlineArg
- newForCommandlineArgAndCwd
- newForPath
- newForUri
- newTmp
- openReadwrite
- openReadwriteAsync
- openReadwriteFinish
- parseName
- peekPath
- pollMountable
- pollMountableFinish
- queryDefaultHandler
- queryDefaultHandlerAsync
- queryDefaultHandlerFinish
- queryExists
- queryFileType
- queryFilesystemInfo
- queryFilesystemInfoAsync
- queryFilesystemInfoFinish
- queryInfo
- queryInfoAsync
- queryInfoFinish
- querySettableAttributes
- queryWritableNamespaces
- read
- readAsync
- readFinish
- replace
- replaceAsync
- replaceContents
- replaceContentsAsync
- replaceContentsBytesAsync
- replaceContentsFinish
- replaceFinish
- replaceReadwrite
- replaceReadwriteAsync
- replaceReadwriteFinish
- resolveRelativePath
- setAttribute
- setAttributeByteString
- setAttributeInt32
- setAttributeInt64
- setAttributeString
- setAttributeUint32
- setAttributeUint64
- setAttributesAsync
- setAttributesFinish
- setAttributesFromInfo
- setDisplayName
- setDisplayNameAsync
- setDisplayNameFinish
- startMountable
- startMountableFinish
- stopMountable
- stopMountableFinish
- supportsThreadContexts
- trash
- trashAsync
- trashFinish
- unmountMountable
- unmountMountableFinish
- unmountMountableWithOperation
- unmountMountableWithOperationFinish
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:
fileNewForPath
if you have a path.fileNewForUri
if you have a URI.fileNewForCommandlineArg
for a command line argument.fileNewTmp
to create a temporary file from a template.fileParseName
from a UTF-8 string gotten fromfileGetParseName
.g_file_new_build_filename()
to create a file from path elements.
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:
fileMountMountable
to mount a mountable file.fileUnmountMountableWithOperation
to unmount a mountable file.fileEjectMountableWithOperation
to eject a mountable file.
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
- newtype File = File (ManagedPtr File)
- noFile :: Maybe File
- class (GObject o, IsDescendantOf File o) => IsFile o
- toFile :: (MonadIO m, IsFile o) => o -> m File
- fileAppendTo :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [FileCreateFlags] -> Maybe b -> m FileOutputStream
- fileAppendToAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [FileCreateFlags] -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileAppendToFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileOutputStream
- fileCopy :: (HasCallStack, MonadIO m, IsFile a, IsFile b, IsCancellable c) => a -> b -> [FileCopyFlags] -> Maybe c -> Maybe FileProgressCallback -> m ()
- fileCopyAttributes :: (HasCallStack, MonadIO m, IsFile a, IsFile b, IsCancellable c) => a -> b -> [FileCopyFlags] -> Maybe c -> m ()
- fileCopyFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileCreate :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [FileCreateFlags] -> Maybe b -> m FileOutputStream
- fileCreateAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [FileCreateFlags] -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileCreateFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileOutputStream
- fileCreateReadwrite :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [FileCreateFlags] -> Maybe b -> m FileIOStream
- fileCreateReadwriteAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [FileCreateFlags] -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileCreateReadwriteFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileIOStream
- fileDelete :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m ()
- fileDeleteAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileDeleteFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileDup :: (HasCallStack, MonadIO m, IsFile a) => a -> m File
- fileEjectMountable :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [MountUnmountFlags] -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileEjectMountableFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileEjectMountableWithOperation :: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) => a -> [MountUnmountFlags] -> Maybe b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- fileEjectMountableWithOperationFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileEnumerateChildren :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> [FileQueryInfoFlags] -> Maybe b -> m FileEnumerator
- fileEnumerateChildrenAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> [FileQueryInfoFlags] -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileEnumerateChildrenFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileEnumerator
- fileEqual :: (HasCallStack, MonadIO m, IsFile a, IsFile b) => a -> b -> m Bool
- fileFindEnclosingMount :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m Mount
- fileFindEnclosingMountAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileFindEnclosingMountFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m Mount
- fileGetBasename :: (HasCallStack, MonadIO m, IsFile a) => a -> m (Maybe [Char])
- fileGetChild :: (HasCallStack, MonadIO m, IsFile a) => a -> [Char] -> m File
- fileGetChildForDisplayName :: (HasCallStack, MonadIO m, IsFile a) => a -> Text -> m File
- fileGetParent :: (HasCallStack, MonadIO m, IsFile a) => a -> m (Maybe File)
- fileGetParseName :: (HasCallStack, MonadIO m, IsFile a) => a -> m Text
- fileGetPath :: (HasCallStack, MonadIO m, IsFile a) => a -> m (Maybe [Char])
- fileGetRelativePath :: (HasCallStack, MonadIO m, IsFile a, IsFile b) => a -> b -> m (Maybe [Char])
- fileGetUri :: (HasCallStack, MonadIO m, IsFile a) => a -> m Text
- fileGetUriScheme :: (HasCallStack, MonadIO m, IsFile a) => a -> m Text
- fileHasParent :: (HasCallStack, MonadIO m, IsFile a, IsFile b) => a -> Maybe b -> m Bool
- fileHasPrefix :: (HasCallStack, MonadIO m, IsFile a, IsFile b) => a -> b -> m Bool
- fileHasUriScheme :: (HasCallStack, MonadIO m, IsFile a) => a -> Text -> m Bool
- fileHash :: (HasCallStack, MonadIO m, IsFile a) => a -> m Word32
- fileIsNative :: (HasCallStack, MonadIO m, IsFile a) => a -> m Bool
- fileLoadBytes :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m (Bytes, Maybe Text)
- fileLoadBytesAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileLoadBytesFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m (Bytes, Maybe Text)
- fileLoadContents :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m (ByteString, Text)
- fileLoadContentsAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileLoadContentsFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m (ByteString, Text)
- fileLoadPartialContentsFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m (ByteString, Text)
- fileMakeDirectory :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m ()
- fileMakeDirectoryAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileMakeDirectoryFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileMakeDirectoryWithParents :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m ()
- fileMakeSymbolicLink :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [Char] -> Maybe b -> m ()
- fileMeasureDiskUsageFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m (Word64, Word64, Word64)
- fileMonitor :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [FileMonitorFlags] -> Maybe b -> m FileMonitor
- fileMonitorDirectory :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [FileMonitorFlags] -> Maybe b -> m FileMonitor
- fileMonitorFile :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [FileMonitorFlags] -> Maybe b -> m FileMonitor
- fileMountEnclosingVolume :: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) => a -> [MountMountFlags] -> Maybe b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- fileMountEnclosingVolumeFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileMountMountable :: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) => a -> [MountMountFlags] -> Maybe b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- fileMountMountableFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m File
- fileMove :: (HasCallStack, MonadIO m, IsFile a, IsFile b, IsCancellable c) => a -> b -> [FileCopyFlags] -> Maybe c -> Maybe FileProgressCallback -> m ()
- fileNewForCommandlineArg :: (HasCallStack, MonadIO m) => [Char] -> m File
- fileNewForCommandlineArgAndCwd :: (HasCallStack, MonadIO m) => [Char] -> [Char] -> m File
- fileNewForPath :: (HasCallStack, MonadIO m) => [Char] -> m File
- fileNewForUri :: (HasCallStack, MonadIO m) => Text -> m File
- fileNewTmp :: (HasCallStack, MonadIO m) => Maybe [Char] -> m (File, FileIOStream)
- fileOpenReadwrite :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m FileIOStream
- fileOpenReadwriteAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileOpenReadwriteFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileIOStream
- fileParseName :: (HasCallStack, MonadIO m) => Text -> m File
- filePeekPath :: (HasCallStack, MonadIO m, IsFile a) => a -> m (Maybe [Char])
- filePollMountable :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- filePollMountableFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileQueryDefaultHandler :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m AppInfo
- fileQueryDefaultHandlerAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileQueryDefaultHandlerFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m AppInfo
- fileQueryExists :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m Bool
- fileQueryFileType :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [FileQueryInfoFlags] -> Maybe b -> m FileType
- fileQueryFilesystemInfo :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> Maybe b -> m FileInfo
- fileQueryFilesystemInfoAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileQueryFilesystemInfoFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileInfo
- fileQueryInfo :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> [FileQueryInfoFlags] -> Maybe b -> m FileInfo
- fileQueryInfoAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> [FileQueryInfoFlags] -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileQueryInfoFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileInfo
- fileQuerySettableAttributes :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m FileAttributeInfoList
- fileQueryWritableNamespaces :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m FileAttributeInfoList
- fileRead :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m FileInputStream
- fileReadAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileReadFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileInputStream
- fileReplace :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe Text -> Bool -> [FileCreateFlags] -> Maybe b -> m FileOutputStream
- fileReplaceAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe Text -> Bool -> [FileCreateFlags] -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileReplaceContents :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> ByteString -> Maybe Text -> Bool -> [FileCreateFlags] -> Maybe b -> m Text
- fileReplaceContentsAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> ByteString -> Maybe Text -> Bool -> [FileCreateFlags] -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileReplaceContentsBytesAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Bytes -> Maybe Text -> Bool -> [FileCreateFlags] -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileReplaceContentsFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m Text
- fileReplaceFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileOutputStream
- fileReplaceReadwrite :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe Text -> Bool -> [FileCreateFlags] -> Maybe b -> m FileIOStream
- fileReplaceReadwriteAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe Text -> Bool -> [FileCreateFlags] -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileReplaceReadwriteFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileIOStream
- fileResolveRelativePath :: (HasCallStack, MonadIO m, IsFile a) => a -> [Char] -> m File
- fileSetAttribute :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> FileAttributeType -> Ptr () -> [FileQueryInfoFlags] -> Maybe b -> m ()
- fileSetAttributeByteString :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> Text -> [FileQueryInfoFlags] -> Maybe b -> m ()
- fileSetAttributeInt32 :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> Int32 -> [FileQueryInfoFlags] -> Maybe b -> m ()
- fileSetAttributeInt64 :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> Int64 -> [FileQueryInfoFlags] -> Maybe b -> m ()
- fileSetAttributeString :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> Text -> [FileQueryInfoFlags] -> Maybe b -> m ()
- fileSetAttributeUint32 :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> Word32 -> [FileQueryInfoFlags] -> Maybe b -> m ()
- fileSetAttributeUint64 :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> Word64 -> [FileQueryInfoFlags] -> Maybe b -> m ()
- fileSetAttributesAsync :: (HasCallStack, MonadIO m, IsFile a, IsFileInfo b, IsCancellable c) => a -> b -> [FileQueryInfoFlags] -> Int32 -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- fileSetAttributesFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m FileInfo
- fileSetAttributesFromInfo :: (HasCallStack, MonadIO m, IsFile a, IsFileInfo b, IsCancellable c) => a -> b -> [FileQueryInfoFlags] -> Maybe c -> m ()
- fileSetDisplayName :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> Maybe b -> m File
- fileSetDisplayNameAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Text -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileSetDisplayNameFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m File
- fileStartMountable :: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) => a -> [DriveStartFlags] -> Maybe b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- fileStartMountableFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileStopMountable :: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) => a -> [MountUnmountFlags] -> Maybe b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- fileStopMountableFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileSupportsThreadContexts :: (HasCallStack, MonadIO m, IsFile a) => a -> m Bool
- fileTrash :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Maybe b -> m ()
- fileTrashAsync :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileTrashFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileUnmountMountable :: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) => a -> [MountUnmountFlags] -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- fileUnmountMountableFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
- fileUnmountMountableWithOperation :: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) => a -> [MountUnmountFlags] -> Maybe b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- fileUnmountMountableWithOperationFinish :: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) => a -> b -> m ()
Exported types
Memory-managed wrapper type.
Instances
Eq File Source # | |
GObject File Source # | |
Defined in GI.Gio.Interfaces.File gobjectType :: IO GType # | |
IsGValue File Source # | Convert |
HasParentTypes File Source # | |
Defined in GI.Gio.Interfaces.File | |
type ParentTypes File Source # | |
Defined in GI.Gio.Interfaces.File |
class (GObject o, IsDescendantOf File o) => IsFile o Source #
Instances
(GObject o, IsDescendantOf File o) => IsFile o Source # | |
Defined in GI.Gio.Interfaces.File |
Methods
Overloaded methods
appendTo
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [FileCreateFlags] |
|
-> Maybe b |
|
-> m FileOutputStream | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [FileCreateFlags] |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileOutputStream | Returns: a valid |
Finishes an asynchronous file append operation started with
fileAppendToAsync
.
copy
:: (HasCallStack, MonadIO m, IsFile a, IsFile b, IsCancellable c) | |
=> a |
|
-> b |
|
-> [FileCopyFlags] |
|
-> Maybe c |
|
-> Maybe FileProgressCallback |
|
-> m () | (Can throw |
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
:: (HasCallStack, MonadIO m, IsFile a, IsFile b, IsCancellable c) | |
=> a |
|
-> b |
|
-> [FileCopyFlags] |
|
-> Maybe c |
|
-> m () | (Can throw |
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
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes copying the file started with fileCopyAsync
.
create
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [FileCreateFlags] |
|
-> Maybe b |
|
-> m FileOutputStream | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [FileCreateFlags] |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileOutputStream | Returns: a |
Finishes an asynchronous file create operation started with
fileCreateAsync
.
createReadwrite
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [FileCreateFlags] |
|
-> Maybe b |
|
-> m FileIOStream | Returns: a |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [FileCreateFlags] |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileIOStream | Returns: a |
Finishes an asynchronous file create operation started with
fileCreateReadwriteAsync
.
Since: 2.22
delete
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m () | (Can throw |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes deleting a file started with fileDeleteAsync
.
Since: 2.34
dup
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> m 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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [MountUnmountFlags] |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Deprecated: (Since version 2.22)Use fileEjectMountableWithOperationFinish
instead.
Finishes an asynchronous eject operation started by
fileEjectMountable
.
ejectMountableWithOperation
fileEjectMountableWithOperation Source #
:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) | |
=> a |
|
-> [MountUnmountFlags] |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes an asynchronous eject operation started by
fileEjectMountableWithOperation
.
Since: 2.22
enumerateChildren
fileEnumerateChildren Source #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> [FileQueryInfoFlags] |
|
-> Maybe b |
|
-> m FileEnumerator | Returns: A |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> [FileQueryInfoFlags] |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileEnumerator | Returns: a |
Finishes an async enumerate children operation.
See fileEnumerateChildrenAsync
.
equal
:: (HasCallStack, MonadIO m, IsFile a, IsFile b) | |
=> a |
|
-> b |
|
-> m Bool | Returns: |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Mount | Returns: a |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m Mount | Returns: |
Finishes an asynchronous find mount request.
See fileFindEnclosingMountAsync
.
getBasename
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> m (Maybe [Char]) | Returns: string containing the |
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
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> [Char] |
|
-> m File | Returns: a |
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 #
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> Text |
|
-> m File | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> m (Maybe File) | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> m Text | Returns: a string containing the |
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
getRelativePath
:: (HasCallStack, MonadIO m, IsFile a, IsFile b) | |
=> a |
|
-> b |
|
-> m (Maybe [Char]) | Returns: string with the relative path from
|
Gets the path for descendant
relative to parent
.
This call does no blocking I/O.
getUri
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> m Text | Returns: a string containing the |
Gets the URI for the file
.
This call does no blocking I/O.
getUriScheme
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> m Text | Returns: a string containing the URI scheme for the given
|
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
hasPrefix
:: (HasCallStack, MonadIO m, IsFile a, IsFile b) | |
=> a |
|
-> b |
|
-> m Bool | Returns: |
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
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> Text |
|
-> m Bool | Returns: |
Checks to see if a File
has a given URI scheme.
This call does no blocking I/O.
hash
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> m Word32 | Returns: 0 if |
Creates a hash value for a File
.
This call does no blocking I/O.
isNative
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m (Bytes, Maybe Text) | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (Bytes, Maybe Text) | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m (ByteString, Text) | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (ByteString, Text) | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (ByteString, Text) | (Can throw |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously creates a directory.
Since: 2.38
makeDirectoryFinish
fileMakeDirectoryFinish Source #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes an asynchronous directory creation, started with
fileMakeDirectoryAsync
.
Since: 2.38
makeDirectoryWithParents
fileMakeDirectoryWithParents Source #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m () | (Can throw |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [Char] |
|
-> Maybe b |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (Word64, Word64, Word64) | (Can throw |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [FileMonitorFlags] |
|
-> Maybe b |
|
-> m FileMonitor | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [FileMonitorFlags] |
|
-> Maybe b |
|
-> m FileMonitor | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [FileMonitorFlags] |
|
-> Maybe b |
|
-> m FileMonitor | Returns: a |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) | |
=> a |
|
-> [MountMountFlags] |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes a mount operation started by fileMountEnclosingVolume
.
mountMountable
:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) | |
=> a |
|
-> [MountMountFlags] |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m File | Returns: a |
Finishes a mount operation. See fileMountMountable
for details.
Finish an asynchronous mount operation that was started
with fileMountMountable
.
move
:: (HasCallStack, MonadIO m, IsFile a, IsFile b, IsCancellable c) | |
=> a |
|
-> b |
|
-> [FileCopyFlags] |
|
-> Maybe c |
|
-> Maybe FileProgressCallback |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m) | |
=> [Char] |
|
-> m File | Returns: a new |
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 #
:: (HasCallStack, MonadIO m) | |
=> [Char] |
|
-> [Char] |
|
-> m File | Returns: a new |
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
:: (HasCallStack, MonadIO m) | |
=> [Char] |
|
-> m File | Returns: a new |
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
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m File | Returns: a new |
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
:: (HasCallStack, MonadIO m) | |
=> Maybe [Char] |
|
-> m (File, FileIOStream) | Returns: a new |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m FileIOStream | Returns: |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileIOStream | Returns: a |
Finishes an asynchronous file read operation started with
fileOpenReadwriteAsync
.
Since: 2.22
parseName
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m File | Returns: a new |
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
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> m (Maybe [Char]) | Returns: string containing the |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes a poll operation. See filePollMountable
for details.
Finish an asynchronous poll operation that was polled
with filePollMountable
.
Since: 2.22
queryDefaultHandler
fileQueryDefaultHandler Source #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m AppInfo | Returns: a |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Int32 | |
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Async version of fileQueryDefaultHandler
.
Since: 2.60
queryDefaultHandlerFinish
fileQueryDefaultHandlerFinish Source #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m AppInfo | Returns: a |
Finishes a fileQueryDefaultHandlerAsync
operation.
Since: 2.60
queryExists
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Bool | Returns: |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [FileQueryInfoFlags] |
|
-> Maybe b |
|
-> m FileType | Returns: The |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Maybe b |
|
-> m FileInfo | Returns: a |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileInfo | Returns: |
Finishes an asynchronous filesystem info query.
See fileQueryFilesystemInfoAsync
.
queryInfo
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> [FileQueryInfoFlags] |
|
-> Maybe b |
|
-> m FileInfo | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> [FileQueryInfoFlags] |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileInfo | Returns: |
Finishes an asynchronous file info query.
See fileQueryInfoAsync
.
querySettableAttributes
fileQuerySettableAttributes Source #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m FileAttributeInfoList | Returns: a |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m FileAttributeInfoList | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m FileInputStream | Returns: |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileInputStream | Returns: a |
Finishes an asynchronous file read operation started with
fileReadAsync
.
replace
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe Text |
|
-> Bool |
|
-> [FileCreateFlags] |
|
-> Maybe b |
|
-> m FileOutputStream | Returns: a |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe Text |
|
-> Bool |
|
-> [FileCreateFlags] |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> ByteString |
|
-> Maybe Text |
|
-> Bool |
|
-> [FileCreateFlags] |
|
-> Maybe b |
|
-> m Text | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> ByteString |
|
-> Maybe Text |
|
-> Bool |
|
-> [FileCreateFlags] |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Bytes |
|
-> Maybe Text |
|
-> Bool |
|
-> [FileCreateFlags] |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m Text | (Can throw |
Finishes an asynchronous replace of the given file
. See
fileReplaceContentsAsync
. Sets newEtag
to the new entity
tag for the document, if present.
replaceFinish
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileOutputStream | Returns: a |
Finishes an asynchronous file replace operation started with
fileReplaceAsync
.
replaceReadwrite
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe Text |
|
-> Bool |
|
-> [FileCreateFlags] |
|
-> Maybe b |
|
-> m FileIOStream | Returns: a |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe Text |
|
-> Bool |
|
-> [FileCreateFlags] |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileIOStream | Returns: a |
Finishes an asynchronous file replace operation started with
fileReplaceReadwriteAsync
.
Since: 2.22
resolveRelativePath
fileResolveRelativePath Source #
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> [Char] |
|
-> m File | Returns: |
Resolves a relative path for file
to an absolute path.
This call does no blocking I/O.
setAttribute
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> FileAttributeType |
|
-> Ptr () |
|
-> [FileQueryInfoFlags] |
|
-> Maybe b |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Text |
|
-> [FileQueryInfoFlags] |
|
-> Maybe b |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Int32 |
|
-> [FileQueryInfoFlags] |
|
-> Maybe b |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Int64 |
|
-> [FileQueryInfoFlags] |
|
-> Maybe b |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Text |
|
-> [FileQueryInfoFlags] |
|
-> Maybe b |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Word32 |
|
-> [FileQueryInfoFlags] |
|
-> Maybe b |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Word64 |
|
-> [FileQueryInfoFlags] |
|
-> Maybe b |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsFileInfo b, IsCancellable c) | |
=> a |
|
-> b |
|
-> [FileQueryInfoFlags] |
|
-> Int32 |
|
-> Maybe c |
|
-> Maybe 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m FileInfo | (Can throw |
Finishes setting an attribute started in fileSetAttributesAsync
.
setAttributesFromInfo
fileSetAttributesFromInfo Source #
:: (HasCallStack, MonadIO m, IsFile a, IsFileInfo b, IsCancellable c) | |
=> a |
|
-> b |
|
-> [FileQueryInfoFlags] |
|
-> Maybe c |
|
-> m () | (Can throw |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Maybe b |
|
-> m File | Returns: a |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Text |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m File | Returns: a |
Finishes setting a display name started with
fileSetDisplayNameAsync
.
startMountable
:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) | |
=> a |
|
-> [DriveStartFlags] |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes a start operation. See fileStartMountable
for details.
Finish an asynchronous start operation that was started
with fileStartMountable
.
Since: 2.22
stopMountable
:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) | |
=> a |
|
-> [MountUnmountFlags] |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes an stop operation, see fileStopMountable
for details.
Finish an asynchronous stop operation that was started
with fileStopMountable
.
Since: 2.22
supportsThreadContexts
fileSupportsThreadContexts Source #
:: (HasCallStack, MonadIO m, IsFile a) | |
=> a |
|
-> m Bool | Returns: Whether or not |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m () | (Can throw |
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
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously sends file
to the Trash location, if possible.
Since: 2.38
trashFinish
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes an asynchronous file trashing operation, started with
fileTrashAsync
.
Since: 2.38
unmountMountable
:: (HasCallStack, MonadIO m, IsFile a, IsCancellable b) | |
=> a |
|
-> [MountUnmountFlags] |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
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 #
:: (HasCallStack, MonadIO m, IsFile a, IsMountOperation b, IsCancellable c) | |
=> a |
|
-> [MountUnmountFlags] |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsFile a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes an unmount operation,
see fileUnmountMountableWithOperation
for details.
Finish an asynchronous unmount operation that was started
with fileUnmountMountableWithOperation
.
Since: 2.22