{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

'GI.Gio.Interfaces.File.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
'GI.Gio.Interfaces.File.File' objects do not represent files, merely an identifier for a
file. All file content I\/O is implemented as streaming operations
(see 'GI.Gio.Objects.InputStream.InputStream' and 'GI.Gio.Objects.OutputStream.OutputStream').

To construct a 'GI.Gio.Interfaces.File.File', you can use:

* 'GI.Gio.Functions.fileNewForPath' if you have a path.
* 'GI.Gio.Functions.fileNewForUri' if you have a URI.
* 'GI.Gio.Functions.fileNewForCommandlineArg' for a command line argument.
* 'GI.Gio.Functions.fileNewTmp' to create a temporary file from a template.
* 'GI.Gio.Functions.fileParseName' from a UTF-8 string gotten from 'GI.Gio.Interfaces.File.fileGetParseName'.


One way to think of a 'GI.Gio.Interfaces.File.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
'GI.Gio.Interfaces.File.File' using 'GI.Gio.Interfaces.File.fileGetParent' to get an identifier for the parent
directory, 'GI.Gio.Interfaces.File.fileGetChild' to get a child within a directory,
'GI.Gio.Interfaces.File.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 'GI.Gio.Interfaces.File.fileGetParent' on two different
files.

All @/GFiles/@ have a basename (get with 'GI.Gio.Interfaces.File.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
'GI.Gio.Constants.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME' attribute with 'GI.Gio.Interfaces.File.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 'GI.Gio.Interfaces.File.File' to use to actually
access the file, because there is no way to go from a display name to
the actual name.

Using 'GI.Gio.Interfaces.File.File' as an identifier has the same weaknesses as using a path
in that there may be multiple aliases for the same file. For instance,
hard or soft links may cause two different @/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
'GI.Gio.Constants.FILE_ATTRIBUTE_ID_FILE' attribute. Note that 'GI.Gio.Interfaces.File.File' does some trivial
canonicalization of pathnames passed in, so that trivial differences in
the path string used at creation (duplicated slashes, slash at end of
path, \".\" or \"..\" path segments, etc) does not create different @/GFiles/@.

Many 'GI.Gio.Interfaces.File.File' operations have both synchronous and asynchronous versions
to suit your application. Asynchronous versions of synchronous functions
simply have @/_async()/@ appended to their function names. The asynchronous
I\/O functions call a 'GI.Gio.Callbacks.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 'GI.Gio.Interfaces.File.File' operations almost always take a noticeable amount of time, and
so do not have synchronous analogs. Notable cases include:

* 'GI.Gio.Interfaces.File.fileMountMountable' to mount a mountable file.
* 'GI.Gio.Interfaces.File.fileUnmountMountableWithOperation' to unmount a mountable file.
* 'GI.Gio.Interfaces.File.fileEjectMountableWithOperation' to eject a mountable file.


## Entity Tags # {@/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
<http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html specification>
for HTTP Etag headers, which are a very similar concept.
-}

module GI.Gio.Interfaces.File
    ( 

-- * Exported types
    File(..)                                ,
    noFile                                  ,
    IsFile                                  ,
    toFile                                  ,


 -- * Methods
-- ** appendTo #method:appendTo#
    FileAppendToMethodInfo                  ,
    fileAppendTo                            ,


-- ** appendToAsync #method:appendToAsync#
    FileAppendToAsyncMethodInfo             ,
    fileAppendToAsync                       ,


-- ** appendToFinish #method:appendToFinish#
    FileAppendToFinishMethodInfo            ,
    fileAppendToFinish                      ,


-- ** copy #method:copy#
    FileCopyMethodInfo                      ,
    fileCopy                                ,


-- ** copyAttributes #method:copyAttributes#
    FileCopyAttributesMethodInfo            ,
    fileCopyAttributes                      ,


-- ** copyFinish #method:copyFinish#
    FileCopyFinishMethodInfo                ,
    fileCopyFinish                          ,


-- ** create #method:create#
    FileCreateMethodInfo                    ,
    fileCreate                              ,


-- ** createAsync #method:createAsync#
    FileCreateAsyncMethodInfo               ,
    fileCreateAsync                         ,


-- ** createFinish #method:createFinish#
    FileCreateFinishMethodInfo              ,
    fileCreateFinish                        ,


-- ** createReadwrite #method:createReadwrite#
    FileCreateReadwriteMethodInfo           ,
    fileCreateReadwrite                     ,


-- ** createReadwriteAsync #method:createReadwriteAsync#
    FileCreateReadwriteAsyncMethodInfo      ,
    fileCreateReadwriteAsync                ,


-- ** createReadwriteFinish #method:createReadwriteFinish#
    FileCreateReadwriteFinishMethodInfo     ,
    fileCreateReadwriteFinish               ,


-- ** delete #method:delete#
    FileDeleteMethodInfo                    ,
    fileDelete                              ,


-- ** deleteAsync #method:deleteAsync#
    FileDeleteAsyncMethodInfo               ,
    fileDeleteAsync                         ,


-- ** deleteFinish #method:deleteFinish#
    FileDeleteFinishMethodInfo              ,
    fileDeleteFinish                        ,


-- ** dup #method:dup#
    FileDupMethodInfo                       ,
    fileDup                                 ,


-- ** ejectMountable #method:ejectMountable#
    FileEjectMountableMethodInfo            ,
    fileEjectMountable                      ,


-- ** ejectMountableFinish #method:ejectMountableFinish#
    FileEjectMountableFinishMethodInfo      ,
    fileEjectMountableFinish                ,


-- ** ejectMountableWithOperation #method:ejectMountableWithOperation#
    FileEjectMountableWithOperationMethodInfo,
    fileEjectMountableWithOperation         ,


-- ** ejectMountableWithOperationFinish #method:ejectMountableWithOperationFinish#
    FileEjectMountableWithOperationFinishMethodInfo,
    fileEjectMountableWithOperationFinish   ,


-- ** enumerateChildren #method:enumerateChildren#
    FileEnumerateChildrenMethodInfo         ,
    fileEnumerateChildren                   ,


-- ** enumerateChildrenAsync #method:enumerateChildrenAsync#
    FileEnumerateChildrenAsyncMethodInfo    ,
    fileEnumerateChildrenAsync              ,


-- ** enumerateChildrenFinish #method:enumerateChildrenFinish#
    FileEnumerateChildrenFinishMethodInfo   ,
    fileEnumerateChildrenFinish             ,


-- ** equal #method:equal#
    FileEqualMethodInfo                     ,
    fileEqual                               ,


-- ** findEnclosingMount #method:findEnclosingMount#
    FileFindEnclosingMountMethodInfo        ,
    fileFindEnclosingMount                  ,


-- ** findEnclosingMountAsync #method:findEnclosingMountAsync#
    FileFindEnclosingMountAsyncMethodInfo   ,
    fileFindEnclosingMountAsync             ,


-- ** findEnclosingMountFinish #method:findEnclosingMountFinish#
    FileFindEnclosingMountFinishMethodInfo  ,
    fileFindEnclosingMountFinish            ,


-- ** getBasename #method:getBasename#
    FileGetBasenameMethodInfo               ,
    fileGetBasename                         ,


-- ** getChild #method:getChild#
    FileGetChildMethodInfo                  ,
    fileGetChild                            ,


-- ** getChildForDisplayName #method:getChildForDisplayName#
    FileGetChildForDisplayNameMethodInfo    ,
    fileGetChildForDisplayName              ,


-- ** getParent #method:getParent#
    FileGetParentMethodInfo                 ,
    fileGetParent                           ,


-- ** getParseName #method:getParseName#
    FileGetParseNameMethodInfo              ,
    fileGetParseName                        ,


-- ** getPath #method:getPath#
    FileGetPathMethodInfo                   ,
    fileGetPath                             ,


-- ** getRelativePath #method:getRelativePath#
    FileGetRelativePathMethodInfo           ,
    fileGetRelativePath                     ,


-- ** getUri #method:getUri#
    FileGetUriMethodInfo                    ,
    fileGetUri                              ,


-- ** getUriScheme #method:getUriScheme#
    FileGetUriSchemeMethodInfo              ,
    fileGetUriScheme                        ,


-- ** hasParent #method:hasParent#
    FileHasParentMethodInfo                 ,
    fileHasParent                           ,


-- ** hasPrefix #method:hasPrefix#
    FileHasPrefixMethodInfo                 ,
    fileHasPrefix                           ,


-- ** hasUriScheme #method:hasUriScheme#
    FileHasUriSchemeMethodInfo              ,
    fileHasUriScheme                        ,


-- ** hash #method:hash#
    FileHashMethodInfo                      ,
    fileHash                                ,


-- ** isNative #method:isNative#
    FileIsNativeMethodInfo                  ,
    fileIsNative                            ,


-- ** loadContents #method:loadContents#
    FileLoadContentsMethodInfo              ,
    fileLoadContents                        ,


-- ** loadContentsAsync #method:loadContentsAsync#
    FileLoadContentsAsyncMethodInfo         ,
    fileLoadContentsAsync                   ,


-- ** loadContentsFinish #method:loadContentsFinish#
    FileLoadContentsFinishMethodInfo        ,
    fileLoadContentsFinish                  ,


-- ** loadPartialContentsFinish #method:loadPartialContentsFinish#
    FileLoadPartialContentsFinishMethodInfo ,
    fileLoadPartialContentsFinish           ,


-- ** makeDirectory #method:makeDirectory#
    FileMakeDirectoryMethodInfo             ,
    fileMakeDirectory                       ,


-- ** makeDirectoryAsync #method:makeDirectoryAsync#
    FileMakeDirectoryAsyncMethodInfo        ,
    fileMakeDirectoryAsync                  ,


-- ** makeDirectoryFinish #method:makeDirectoryFinish#
    FileMakeDirectoryFinishMethodInfo       ,
    fileMakeDirectoryFinish                 ,


-- ** makeDirectoryWithParents #method:makeDirectoryWithParents#
    FileMakeDirectoryWithParentsMethodInfo  ,
    fileMakeDirectoryWithParents            ,


-- ** makeSymbolicLink #method:makeSymbolicLink#
    FileMakeSymbolicLinkMethodInfo          ,
    fileMakeSymbolicLink                    ,


-- ** measureDiskUsageFinish #method:measureDiskUsageFinish#
    FileMeasureDiskUsageFinishMethodInfo    ,
    fileMeasureDiskUsageFinish              ,


-- ** monitor #method:monitor#
    FileMonitorMethodInfo                   ,
    fileMonitor                             ,


-- ** monitorDirectory #method:monitorDirectory#
    FileMonitorDirectoryMethodInfo          ,
    fileMonitorDirectory                    ,


-- ** monitorFile #method:monitorFile#
    FileMonitorFileMethodInfo               ,
    fileMonitorFile                         ,


-- ** mountEnclosingVolume #method:mountEnclosingVolume#
    FileMountEnclosingVolumeMethodInfo      ,
    fileMountEnclosingVolume                ,


-- ** mountEnclosingVolumeFinish #method:mountEnclosingVolumeFinish#
    FileMountEnclosingVolumeFinishMethodInfo,
    fileMountEnclosingVolumeFinish          ,


-- ** mountMountable #method:mountMountable#
    FileMountMountableMethodInfo            ,
    fileMountMountable                      ,


-- ** mountMountableFinish #method:mountMountableFinish#
    FileMountMountableFinishMethodInfo      ,
    fileMountMountableFinish                ,


-- ** move #method:move#
    FileMoveMethodInfo                      ,
    fileMove                                ,


-- ** newForCommandlineArg #method:newForCommandlineArg#
    fileNewForCommandlineArg                ,


-- ** newForCommandlineArgAndCwd #method:newForCommandlineArgAndCwd#
    fileNewForCommandlineArgAndCwd          ,


-- ** newForPath #method:newForPath#
    fileNewForPath                          ,


-- ** newForUri #method:newForUri#
    fileNewForUri                           ,


-- ** newTmp #method:newTmp#
    fileNewTmp                              ,


-- ** openReadwrite #method:openReadwrite#
    FileOpenReadwriteMethodInfo             ,
    fileOpenReadwrite                       ,


-- ** openReadwriteAsync #method:openReadwriteAsync#
    FileOpenReadwriteAsyncMethodInfo        ,
    fileOpenReadwriteAsync                  ,


-- ** openReadwriteFinish #method:openReadwriteFinish#
    FileOpenReadwriteFinishMethodInfo       ,
    fileOpenReadwriteFinish                 ,


-- ** parseName #method:parseName#
    fileParseName                           ,


-- ** pollMountable #method:pollMountable#
    FilePollMountableMethodInfo             ,
    filePollMountable                       ,


-- ** pollMountableFinish #method:pollMountableFinish#
    FilePollMountableFinishMethodInfo       ,
    filePollMountableFinish                 ,


-- ** queryDefaultHandler #method:queryDefaultHandler#
    FileQueryDefaultHandlerMethodInfo       ,
    fileQueryDefaultHandler                 ,


-- ** queryExists #method:queryExists#
    FileQueryExistsMethodInfo               ,
    fileQueryExists                         ,


-- ** queryFileType #method:queryFileType#
    FileQueryFileTypeMethodInfo             ,
    fileQueryFileType                       ,


-- ** queryFilesystemInfo #method:queryFilesystemInfo#
    FileQueryFilesystemInfoMethodInfo       ,
    fileQueryFilesystemInfo                 ,


-- ** queryFilesystemInfoAsync #method:queryFilesystemInfoAsync#
    FileQueryFilesystemInfoAsyncMethodInfo  ,
    fileQueryFilesystemInfoAsync            ,


-- ** queryFilesystemInfoFinish #method:queryFilesystemInfoFinish#
    FileQueryFilesystemInfoFinishMethodInfo ,
    fileQueryFilesystemInfoFinish           ,


-- ** queryInfo #method:queryInfo#
    FileQueryInfoMethodInfo                 ,
    fileQueryInfo                           ,


-- ** queryInfoAsync #method:queryInfoAsync#
    FileQueryInfoAsyncMethodInfo            ,
    fileQueryInfoAsync                      ,


-- ** queryInfoFinish #method:queryInfoFinish#
    FileQueryInfoFinishMethodInfo           ,
    fileQueryInfoFinish                     ,


-- ** querySettableAttributes #method:querySettableAttributes#
    FileQuerySettableAttributesMethodInfo   ,
    fileQuerySettableAttributes             ,


-- ** queryWritableNamespaces #method:queryWritableNamespaces#
    FileQueryWritableNamespacesMethodInfo   ,
    fileQueryWritableNamespaces             ,


-- ** read #method:read#
    FileReadMethodInfo                      ,
    fileRead                                ,


-- ** readAsync #method:readAsync#
    FileReadAsyncMethodInfo                 ,
    fileReadAsync                           ,


-- ** readFinish #method:readFinish#
    FileReadFinishMethodInfo                ,
    fileReadFinish                          ,


-- ** replace #method:replace#
    FileReplaceMethodInfo                   ,
    fileReplace                             ,


-- ** replaceAsync #method:replaceAsync#
    FileReplaceAsyncMethodInfo              ,
    fileReplaceAsync                        ,


-- ** replaceContents #method:replaceContents#
    FileReplaceContentsMethodInfo           ,
    fileReplaceContents                     ,


-- ** replaceContentsAsync #method:replaceContentsAsync#
    FileReplaceContentsAsyncMethodInfo      ,
    fileReplaceContentsAsync                ,


-- ** replaceContentsBytesAsync #method:replaceContentsBytesAsync#
    FileReplaceContentsBytesAsyncMethodInfo ,
    fileReplaceContentsBytesAsync           ,


-- ** replaceContentsFinish #method:replaceContentsFinish#
    FileReplaceContentsFinishMethodInfo     ,
    fileReplaceContentsFinish               ,


-- ** replaceFinish #method:replaceFinish#
    FileReplaceFinishMethodInfo             ,
    fileReplaceFinish                       ,


-- ** replaceReadwrite #method:replaceReadwrite#
    FileReplaceReadwriteMethodInfo          ,
    fileReplaceReadwrite                    ,


-- ** replaceReadwriteAsync #method:replaceReadwriteAsync#
    FileReplaceReadwriteAsyncMethodInfo     ,
    fileReplaceReadwriteAsync               ,


-- ** replaceReadwriteFinish #method:replaceReadwriteFinish#
    FileReplaceReadwriteFinishMethodInfo    ,
    fileReplaceReadwriteFinish              ,


-- ** resolveRelativePath #method:resolveRelativePath#
    FileResolveRelativePathMethodInfo       ,
    fileResolveRelativePath                 ,


-- ** setAttribute #method:setAttribute#
    FileSetAttributeMethodInfo              ,
    fileSetAttribute                        ,


-- ** setAttributeByteString #method:setAttributeByteString#
    FileSetAttributeByteStringMethodInfo    ,
    fileSetAttributeByteString              ,


-- ** setAttributeInt32 #method:setAttributeInt32#
    FileSetAttributeInt32MethodInfo         ,
    fileSetAttributeInt32                   ,


-- ** setAttributeInt64 #method:setAttributeInt64#
    FileSetAttributeInt64MethodInfo         ,
    fileSetAttributeInt64                   ,


-- ** setAttributeString #method:setAttributeString#
    FileSetAttributeStringMethodInfo        ,
    fileSetAttributeString                  ,


-- ** setAttributeUint32 #method:setAttributeUint32#
    FileSetAttributeUint32MethodInfo        ,
    fileSetAttributeUint32                  ,


-- ** setAttributeUint64 #method:setAttributeUint64#
    FileSetAttributeUint64MethodInfo        ,
    fileSetAttributeUint64                  ,


-- ** setAttributesAsync #method:setAttributesAsync#
    FileSetAttributesAsyncMethodInfo        ,
    fileSetAttributesAsync                  ,


-- ** setAttributesFinish #method:setAttributesFinish#
    FileSetAttributesFinishMethodInfo       ,
    fileSetAttributesFinish                 ,


-- ** setAttributesFromInfo #method:setAttributesFromInfo#
    FileSetAttributesFromInfoMethodInfo     ,
    fileSetAttributesFromInfo               ,


-- ** setDisplayName #method:setDisplayName#
    FileSetDisplayNameMethodInfo            ,
    fileSetDisplayName                      ,


-- ** setDisplayNameAsync #method:setDisplayNameAsync#
    FileSetDisplayNameAsyncMethodInfo       ,
    fileSetDisplayNameAsync                 ,


-- ** setDisplayNameFinish #method:setDisplayNameFinish#
    FileSetDisplayNameFinishMethodInfo      ,
    fileSetDisplayNameFinish                ,


-- ** startMountable #method:startMountable#
    FileStartMountableMethodInfo            ,
    fileStartMountable                      ,


-- ** startMountableFinish #method:startMountableFinish#
    FileStartMountableFinishMethodInfo      ,
    fileStartMountableFinish                ,


-- ** stopMountable #method:stopMountable#
    FileStopMountableMethodInfo             ,
    fileStopMountable                       ,


-- ** stopMountableFinish #method:stopMountableFinish#
    FileStopMountableFinishMethodInfo       ,
    fileStopMountableFinish                 ,


-- ** supportsThreadContexts #method:supportsThreadContexts#
    FileSupportsThreadContextsMethodInfo    ,
    fileSupportsThreadContexts              ,


-- ** trash #method:trash#
    FileTrashMethodInfo                     ,
    fileTrash                               ,


-- ** trashAsync #method:trashAsync#
    FileTrashAsyncMethodInfo                ,
    fileTrashAsync                          ,


-- ** trashFinish #method:trashFinish#
    FileTrashFinishMethodInfo               ,
    fileTrashFinish                         ,


-- ** unmountMountable #method:unmountMountable#
    FileUnmountMountableMethodInfo          ,
    fileUnmountMountable                    ,


-- ** unmountMountableFinish #method:unmountMountableFinish#
    FileUnmountMountableFinishMethodInfo    ,
    fileUnmountMountableFinish              ,


-- ** unmountMountableWithOperation #method:unmountMountableWithOperation#
    FileUnmountMountableWithOperationMethodInfo,
    fileUnmountMountableWithOperation       ,


-- ** unmountMountableWithOperationFinish #method:unmountMountableWithOperationFinish#
    FileUnmountMountableWithOperationFinishMethodInfo,
    fileUnmountMountableWithOperationFinish ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AppInfo as Gio.AppInfo
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Mount as Gio.Mount
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.FileEnumerator as Gio.FileEnumerator
import {-# SOURCE #-} qualified GI.Gio.Objects.FileIOStream as Gio.FileIOStream
import {-# SOURCE #-} qualified GI.Gio.Objects.FileInfo as Gio.FileInfo
import {-# SOURCE #-} qualified GI.Gio.Objects.FileInputStream as Gio.FileInputStream
import {-# SOURCE #-} qualified GI.Gio.Objects.FileMonitor as Gio.FileMonitor
import {-# SOURCE #-} qualified GI.Gio.Objects.FileOutputStream as Gio.FileOutputStream
import {-# SOURCE #-} qualified GI.Gio.Objects.MountOperation as Gio.MountOperation
import {-# SOURCE #-} qualified GI.Gio.Structs.FileAttributeInfoList as Gio.FileAttributeInfoList

-- interface File 
newtype File = File (ManagedPtr File)
noFile :: Maybe File
noFile = Nothing

type family ResolveFileMethod (t :: Symbol) (o :: *) :: * where
    ResolveFileMethod "appendTo" o = FileAppendToMethodInfo
    ResolveFileMethod "appendToAsync" o = FileAppendToAsyncMethodInfo
    ResolveFileMethod "appendToFinish" o = FileAppendToFinishMethodInfo
    ResolveFileMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveFileMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveFileMethod "copy" o = FileCopyMethodInfo
    ResolveFileMethod "copyAttributes" o = FileCopyAttributesMethodInfo
    ResolveFileMethod "copyFinish" o = FileCopyFinishMethodInfo
    ResolveFileMethod "create" o = FileCreateMethodInfo
    ResolveFileMethod "createAsync" o = FileCreateAsyncMethodInfo
    ResolveFileMethod "createFinish" o = FileCreateFinishMethodInfo
    ResolveFileMethod "createReadwrite" o = FileCreateReadwriteMethodInfo
    ResolveFileMethod "createReadwriteAsync" o = FileCreateReadwriteAsyncMethodInfo
    ResolveFileMethod "createReadwriteFinish" o = FileCreateReadwriteFinishMethodInfo
    ResolveFileMethod "delete" o = FileDeleteMethodInfo
    ResolveFileMethod "deleteAsync" o = FileDeleteAsyncMethodInfo
    ResolveFileMethod "deleteFinish" o = FileDeleteFinishMethodInfo
    ResolveFileMethod "dup" o = FileDupMethodInfo
    ResolveFileMethod "ejectMountable" o = FileEjectMountableMethodInfo
    ResolveFileMethod "ejectMountableFinish" o = FileEjectMountableFinishMethodInfo
    ResolveFileMethod "ejectMountableWithOperation" o = FileEjectMountableWithOperationMethodInfo
    ResolveFileMethod "ejectMountableWithOperationFinish" o = FileEjectMountableWithOperationFinishMethodInfo
    ResolveFileMethod "enumerateChildren" o = FileEnumerateChildrenMethodInfo
    ResolveFileMethod "enumerateChildrenAsync" o = FileEnumerateChildrenAsyncMethodInfo
    ResolveFileMethod "enumerateChildrenFinish" o = FileEnumerateChildrenFinishMethodInfo
    ResolveFileMethod "equal" o = FileEqualMethodInfo
    ResolveFileMethod "findEnclosingMount" o = FileFindEnclosingMountMethodInfo
    ResolveFileMethod "findEnclosingMountAsync" o = FileFindEnclosingMountAsyncMethodInfo
    ResolveFileMethod "findEnclosingMountFinish" o = FileFindEnclosingMountFinishMethodInfo
    ResolveFileMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveFileMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveFileMethod "hasParent" o = FileHasParentMethodInfo
    ResolveFileMethod "hasPrefix" o = FileHasPrefixMethodInfo
    ResolveFileMethod "hasUriScheme" o = FileHasUriSchemeMethodInfo
    ResolveFileMethod "hash" o = FileHashMethodInfo
    ResolveFileMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveFileMethod "isNative" o = FileIsNativeMethodInfo
    ResolveFileMethod "loadContents" o = FileLoadContentsMethodInfo
    ResolveFileMethod "loadContentsAsync" o = FileLoadContentsAsyncMethodInfo
    ResolveFileMethod "loadContentsFinish" o = FileLoadContentsFinishMethodInfo
    ResolveFileMethod "loadPartialContentsFinish" o = FileLoadPartialContentsFinishMethodInfo
    ResolveFileMethod "makeDirectory" o = FileMakeDirectoryMethodInfo
    ResolveFileMethod "makeDirectoryAsync" o = FileMakeDirectoryAsyncMethodInfo
    ResolveFileMethod "makeDirectoryFinish" o = FileMakeDirectoryFinishMethodInfo
    ResolveFileMethod "makeDirectoryWithParents" o = FileMakeDirectoryWithParentsMethodInfo
    ResolveFileMethod "makeSymbolicLink" o = FileMakeSymbolicLinkMethodInfo
    ResolveFileMethod "measureDiskUsageFinish" o = FileMeasureDiskUsageFinishMethodInfo
    ResolveFileMethod "monitor" o = FileMonitorMethodInfo
    ResolveFileMethod "monitorDirectory" o = FileMonitorDirectoryMethodInfo
    ResolveFileMethod "monitorFile" o = FileMonitorFileMethodInfo
    ResolveFileMethod "mountEnclosingVolume" o = FileMountEnclosingVolumeMethodInfo
    ResolveFileMethod "mountEnclosingVolumeFinish" o = FileMountEnclosingVolumeFinishMethodInfo
    ResolveFileMethod "mountMountable" o = FileMountMountableMethodInfo
    ResolveFileMethod "mountMountableFinish" o = FileMountMountableFinishMethodInfo
    ResolveFileMethod "move" o = FileMoveMethodInfo
    ResolveFileMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveFileMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveFileMethod "openReadwrite" o = FileOpenReadwriteMethodInfo
    ResolveFileMethod "openReadwriteAsync" o = FileOpenReadwriteAsyncMethodInfo
    ResolveFileMethod "openReadwriteFinish" o = FileOpenReadwriteFinishMethodInfo
    ResolveFileMethod "pollMountable" o = FilePollMountableMethodInfo
    ResolveFileMethod "pollMountableFinish" o = FilePollMountableFinishMethodInfo
    ResolveFileMethod "queryDefaultHandler" o = FileQueryDefaultHandlerMethodInfo
    ResolveFileMethod "queryExists" o = FileQueryExistsMethodInfo
    ResolveFileMethod "queryFileType" o = FileQueryFileTypeMethodInfo
    ResolveFileMethod "queryFilesystemInfo" o = FileQueryFilesystemInfoMethodInfo
    ResolveFileMethod "queryFilesystemInfoAsync" o = FileQueryFilesystemInfoAsyncMethodInfo
    ResolveFileMethod "queryFilesystemInfoFinish" o = FileQueryFilesystemInfoFinishMethodInfo
    ResolveFileMethod "queryInfo" o = FileQueryInfoMethodInfo
    ResolveFileMethod "queryInfoAsync" o = FileQueryInfoAsyncMethodInfo
    ResolveFileMethod "queryInfoFinish" o = FileQueryInfoFinishMethodInfo
    ResolveFileMethod "querySettableAttributes" o = FileQuerySettableAttributesMethodInfo
    ResolveFileMethod "queryWritableNamespaces" o = FileQueryWritableNamespacesMethodInfo
    ResolveFileMethod "read" o = FileReadMethodInfo
    ResolveFileMethod "readAsync" o = FileReadAsyncMethodInfo
    ResolveFileMethod "readFinish" o = FileReadFinishMethodInfo
    ResolveFileMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveFileMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveFileMethod "replace" o = FileReplaceMethodInfo
    ResolveFileMethod "replaceAsync" o = FileReplaceAsyncMethodInfo
    ResolveFileMethod "replaceContents" o = FileReplaceContentsMethodInfo
    ResolveFileMethod "replaceContentsAsync" o = FileReplaceContentsAsyncMethodInfo
    ResolveFileMethod "replaceContentsBytesAsync" o = FileReplaceContentsBytesAsyncMethodInfo
    ResolveFileMethod "replaceContentsFinish" o = FileReplaceContentsFinishMethodInfo
    ResolveFileMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveFileMethod "replaceFinish" o = FileReplaceFinishMethodInfo
    ResolveFileMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveFileMethod "replaceReadwrite" o = FileReplaceReadwriteMethodInfo
    ResolveFileMethod "replaceReadwriteAsync" o = FileReplaceReadwriteAsyncMethodInfo
    ResolveFileMethod "replaceReadwriteFinish" o = FileReplaceReadwriteFinishMethodInfo
    ResolveFileMethod "resolveRelativePath" o = FileResolveRelativePathMethodInfo
    ResolveFileMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveFileMethod "startMountable" o = FileStartMountableMethodInfo
    ResolveFileMethod "startMountableFinish" o = FileStartMountableFinishMethodInfo
    ResolveFileMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveFileMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveFileMethod "stopMountable" o = FileStopMountableMethodInfo
    ResolveFileMethod "stopMountableFinish" o = FileStopMountableFinishMethodInfo
    ResolveFileMethod "supportsThreadContexts" o = FileSupportsThreadContextsMethodInfo
    ResolveFileMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveFileMethod "trash" o = FileTrashMethodInfo
    ResolveFileMethod "trashAsync" o = FileTrashAsyncMethodInfo
    ResolveFileMethod "trashFinish" o = FileTrashFinishMethodInfo
    ResolveFileMethod "unmountMountable" o = FileUnmountMountableMethodInfo
    ResolveFileMethod "unmountMountableFinish" o = FileUnmountMountableFinishMethodInfo
    ResolveFileMethod "unmountMountableWithOperation" o = FileUnmountMountableWithOperationMethodInfo
    ResolveFileMethod "unmountMountableWithOperationFinish" o = FileUnmountMountableWithOperationFinishMethodInfo
    ResolveFileMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveFileMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveFileMethod "getBasename" o = FileGetBasenameMethodInfo
    ResolveFileMethod "getChild" o = FileGetChildMethodInfo
    ResolveFileMethod "getChildForDisplayName" o = FileGetChildForDisplayNameMethodInfo
    ResolveFileMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveFileMethod "getParent" o = FileGetParentMethodInfo
    ResolveFileMethod "getParseName" o = FileGetParseNameMethodInfo
    ResolveFileMethod "getPath" o = FileGetPathMethodInfo
    ResolveFileMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveFileMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveFileMethod "getRelativePath" o = FileGetRelativePathMethodInfo
    ResolveFileMethod "getUri" o = FileGetUriMethodInfo
    ResolveFileMethod "getUriScheme" o = FileGetUriSchemeMethodInfo
    ResolveFileMethod "setAttribute" o = FileSetAttributeMethodInfo
    ResolveFileMethod "setAttributeByteString" o = FileSetAttributeByteStringMethodInfo
    ResolveFileMethod "setAttributeInt32" o = FileSetAttributeInt32MethodInfo
    ResolveFileMethod "setAttributeInt64" o = FileSetAttributeInt64MethodInfo
    ResolveFileMethod "setAttributeString" o = FileSetAttributeStringMethodInfo
    ResolveFileMethod "setAttributeUint32" o = FileSetAttributeUint32MethodInfo
    ResolveFileMethod "setAttributeUint64" o = FileSetAttributeUint64MethodInfo
    ResolveFileMethod "setAttributesAsync" o = FileSetAttributesAsyncMethodInfo
    ResolveFileMethod "setAttributesFinish" o = FileSetAttributesFinishMethodInfo
    ResolveFileMethod "setAttributesFromInfo" o = FileSetAttributesFromInfoMethodInfo
    ResolveFileMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveFileMethod "setDisplayName" o = FileSetDisplayNameMethodInfo
    ResolveFileMethod "setDisplayNameAsync" o = FileSetDisplayNameAsyncMethodInfo
    ResolveFileMethod "setDisplayNameFinish" o = FileSetDisplayNameFinishMethodInfo
    ResolveFileMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveFileMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveFileMethod t File, O.MethodInfo info File p) => O.IsLabelProxy t (File -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveFileMethod t File, O.MethodInfo info File p) => O.IsLabel t (File -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

instance O.HasAttributeList File
type instance O.AttributeList File = FileAttributeList
type FileAttributeList = ('[ ] :: [(Symbol, *)])

type instance O.SignalList File = FileSignalList
type FileSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

foreign import ccall "g_file_get_type"
    c_g_file_get_type :: IO GType

instance GObject File where
    gobjectType _ = c_g_file_get_type
    

class GObject o => IsFile o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError File a) =>
    IsFile a
#endif
instance IsFile File
instance GObject.Object.IsObject File

toFile :: IsFile o => o -> IO File
toFile = unsafeCastTo File

-- method File::append_to
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileOutputStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_append_to" g_file_append_to :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileOutputStream.FileOutputStream)

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be
returned.

Some file systems don\'t allow all file names, and may return an
'GI.Gio.Enums.IOErrorEnumInvalidFilename' error. If the file is a directory the
'GI.Gio.Enums.IOErrorEnumIsDirectory' error will be returned. Other errors are
possible too, and depend on what kind of filesystem the file is on.
-}
fileAppendTo ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileOutputStream.FileOutputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileOutputStream.FileOutputStream', or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileAppendTo file flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_append_to file' flags' maybeCancellable
        checkUnexpectedReturnNULL "fileAppendTo" result
        result' <- (wrapObject Gio.FileOutputStream.FileOutputStream) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileAppendToMethodInfo
instance (signature ~ ([Gio.Flags.FileCreateFlags] -> Maybe (b) -> m Gio.FileOutputStream.FileOutputStream), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileAppendToMethodInfo a signature where
    overloadedMethod _ = fileAppendTo

-- method File::append_to_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_append_to_async" g_file_append_to_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously opens /@file@/ for appending.

For more details, see 'GI.Gio.Interfaces.File.fileAppendTo' which is
the synchronous version of this call.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileAppendToFinish' to get the result
of the operation.
-}
fileAppendToAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileAppendToAsync file flags ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_append_to_async file' flags' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileAppendToAsyncMethodInfo
instance (signature ~ ([Gio.Flags.FileCreateFlags] -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileAppendToAsyncMethodInfo a signature where
    overloadedMethod _ = fileAppendToAsync

-- method File::append_to_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileOutputStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_append_to_finish" g_file_append_to_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileOutputStream.FileOutputStream)

{- |
Finishes an asynchronous file append operation started with
'GI.Gio.Interfaces.File.fileAppendToAsync'.
-}
fileAppendToFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.FileOutputStream.FileOutputStream
    {- ^ __Returns:__ a valid 'GI.Gio.Objects.FileOutputStream.FileOutputStream'
    or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileAppendToFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_append_to_finish file' res'
        checkUnexpectedReturnNULL "fileAppendToFinish" result
        result' <- (wrapObject Gio.FileOutputStream.FileOutputStream) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileAppendToFinishMethodInfo
instance (signature ~ (b -> m Gio.FileOutputStream.FileOutputStream), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileAppendToFinishMethodInfo a signature where
    overloadedMethod _ = fileAppendToFinish

-- method File::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destination", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destination #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCopyFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "set of #GFileCopyFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "progress_callback", argType = TInterface (Name {namespace = "Gio", name = "FileProgressCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to callback with\n    progress information, or %NULL if progress information is not needed", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "progress_callback_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @progress_callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_copy" g_file_copy :: 
    Ptr File ->                             -- source : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr File ->                             -- destination : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCopyFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_FileProgressCallback -> -- progress_callback : TInterface (Name {namespace = "Gio", name = "FileProgressCallback"})
    Ptr () ->                               -- progress_callback_data : TBasicType TPtr
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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 /@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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

If /@progressCallback@/ is not 'Nothing', then the operation can be monitored
by setting this to a 'GI.Gio.Callbacks.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 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumExists' is returned.

If trying to overwrite a file over a directory, the 'GI.Gio.Enums.IOErrorEnumIsDirectory'
error is returned. If trying to overwrite a directory with a directory the
'GI.Gio.Enums.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
'GI.Gio.Enums.IOErrorEnumWouldRecurse' error is returned.

If you are interested in copying the 'GI.Gio.Interfaces.File.File' object itself (not the on-disk
file), see 'GI.Gio.Interfaces.File.fileDup'.
-}
fileCopy ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, IsFile b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@source@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@destination@/: destination 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileCopyFlags]
    {- ^ /@flags@/: set of 'GI.Gio.Flags.FileCopyFlags' -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.FileProgressCallback)
    {- ^ /@progressCallback@/: function to callback with
    progress information, or 'Nothing' if progress information is not needed -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileCopy source destination flags cancellable progressCallback = liftIO $ do
    source' <- unsafeManagedPtrCastPtr source
    destination' <- unsafeManagedPtrCastPtr destination
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    maybeProgressCallback <- case progressCallback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jProgressCallback -> do
            jProgressCallback' <- Gio.Callbacks.mk_FileProgressCallback (Gio.Callbacks.wrap_FileProgressCallback Nothing (Gio.Callbacks.drop_closures_FileProgressCallback jProgressCallback))
            return jProgressCallback'
    let progressCallbackData = nullPtr
    onException (do
        _ <- propagateGError $ g_file_copy source' destination' flags' maybeCancellable maybeProgressCallback progressCallbackData
        safeFreeFunPtr $ castFunPtrToPtr maybeProgressCallback
        touchManagedPtr source
        touchManagedPtr destination
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        safeFreeFunPtr $ castFunPtrToPtr maybeProgressCallback
        return ()
     )

data FileCopyMethodInfo
instance (signature ~ (b -> [Gio.Flags.FileCopyFlags] -> Maybe (c) -> Maybe (Gio.Callbacks.FileProgressCallback) -> m ()), MonadIO m, IsFile a, IsFile b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileCopyMethodInfo a signature where
    overloadedMethod _ = fileCopy

-- method File::copy_attributes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFile with attributes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destination", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFile to copy attributes to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCopyFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCopyFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_copy_attributes" g_file_copy_attributes :: 
    Ptr File ->                             -- source : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr File ->                             -- destination : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCopyFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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.
-}
fileCopyAttributes ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, IsFile b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@source@/: a 'GI.Gio.Interfaces.File.File' with attributes -}
    -> b
    {- ^ /@destination@/: a 'GI.Gio.Interfaces.File.File' to copy attributes to -}
    -> [Gio.Flags.FileCopyFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCopyFlags' -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileCopyAttributes source destination flags cancellable = liftIO $ do
    source' <- unsafeManagedPtrCastPtr source
    destination' <- unsafeManagedPtrCastPtr destination
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_copy_attributes source' destination' flags' maybeCancellable
        touchManagedPtr source
        touchManagedPtr destination
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data FileCopyAttributesMethodInfo
instance (signature ~ (b -> [Gio.Flags.FileCopyFlags] -> Maybe (c) -> m ()), MonadIO m, IsFile a, IsFile b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileCopyAttributesMethodInfo a signature where
    overloadedMethod _ = fileCopyAttributes

-- method File::copy_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_copy_finish" g_file_copy_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes copying the file started with @/g_file_copy_async()/@.
-}
fileCopyFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileCopyFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        _ <- propagateGError $ g_file_copy_finish file' res'
        touchManagedPtr file
        touchManagedPtr res
        return ()
     ) (do
        return ()
     )

data FileCopyFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileCopyFinishMethodInfo a signature where
    overloadedMethod _ = fileCopyFinish

-- method File::create
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileOutputStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_create" g_file_create :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileOutputStream.FileOutputStream)

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be
returned.

If a file or directory with this name already exists the
'GI.Gio.Enums.IOErrorEnumExists' error will be returned. Some file systems don\'t
allow all file names, and may return an 'GI.Gio.Enums.IOErrorEnumInvalidFilename'
error, and if the name is to long 'GI.Gio.Enums.IOErrorEnumFilenameTooLong' will
be returned. Other errors are possible too, and depend on what kind
of filesystem the file is on.
-}
fileCreate ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileOutputStream.FileOutputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileOutputStream.FileOutputStream' for the newly created
    file, or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileCreate file flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_create file' flags' maybeCancellable
        checkUnexpectedReturnNULL "fileCreate" result
        result' <- (wrapObject Gio.FileOutputStream.FileOutputStream) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileCreateMethodInfo
instance (signature ~ ([Gio.Flags.FileCreateFlags] -> Maybe (b) -> m Gio.FileOutputStream.FileOutputStream), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileCreateMethodInfo a signature where
    overloadedMethod _ = fileCreate

-- method File::create_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_create_async" g_file_create_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

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

For more details, see 'GI.Gio.Interfaces.File.fileCreate' which is
the synchronous version of this call.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileCreateFinish' to get the result
of the operation.
-}
fileCreateAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileCreateAsync file flags ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_create_async file' flags' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileCreateAsyncMethodInfo
instance (signature ~ ([Gio.Flags.FileCreateFlags] -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileCreateAsyncMethodInfo a signature where
    overloadedMethod _ = fileCreateAsync

-- method File::create_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileOutputStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_create_finish" g_file_create_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileOutputStream.FileOutputStream)

{- |
Finishes an asynchronous file create operation started with
'GI.Gio.Interfaces.File.fileCreateAsync'.
-}
fileCreateFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.FileOutputStream.FileOutputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileOutputStream.FileOutputStream' or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileCreateFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_create_finish file' res'
        checkUnexpectedReturnNULL "fileCreateFinish" result
        result' <- (wrapObject Gio.FileOutputStream.FileOutputStream) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileCreateFinishMethodInfo
instance (signature ~ (b -> m Gio.FileOutputStream.FileOutputStream), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileCreateFinishMethodInfo a signature where
    overloadedMethod _ = fileCreateFinish

-- method File::create_readwrite
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileIOStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_create_readwrite" g_file_create_readwrite :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileIOStream.FileIOStream)

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be
returned.

If a file or directory with this name already exists, the
'GI.Gio.Enums.IOErrorEnumExists' error will be returned. Some file systems don\'t
allow all file names, and may return an 'GI.Gio.Enums.IOErrorEnumInvalidFilename'
error, and if the name is too long, 'GI.Gio.Enums.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
-}
fileCreateReadwrite ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: a 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileIOStream.FileIOStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileIOStream.FileIOStream' for the newly created
    file, or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileCreateReadwrite file flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_create_readwrite file' flags' maybeCancellable
        checkUnexpectedReturnNULL "fileCreateReadwrite" result
        result' <- (wrapObject Gio.FileIOStream.FileIOStream) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileCreateReadwriteMethodInfo
instance (signature ~ ([Gio.Flags.FileCreateFlags] -> Maybe (b) -> m Gio.FileIOStream.FileIOStream), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileCreateReadwriteMethodInfo a signature where
    overloadedMethod _ = fileCreateReadwrite

-- method File::create_readwrite_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_create_readwrite_async" g_file_create_readwrite_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
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 'GI.Gio.Interfaces.File.fileCreateReadwrite' which is
the synchronous version of this call.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileCreateReadwriteFinish' to get
the result of the operation.

@since 2.22
-}
fileCreateReadwriteAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileCreateReadwriteAsync file flags ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_create_readwrite_async file' flags' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileCreateReadwriteAsyncMethodInfo
instance (signature ~ ([Gio.Flags.FileCreateFlags] -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileCreateReadwriteAsyncMethodInfo a signature where
    overloadedMethod _ = fileCreateReadwriteAsync

-- method File::create_readwrite_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileIOStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_create_readwrite_finish" g_file_create_readwrite_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileIOStream.FileIOStream)

{- |
Finishes an asynchronous file create operation started with
'GI.Gio.Interfaces.File.fileCreateReadwriteAsync'.

@since 2.22
-}
fileCreateReadwriteFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.FileIOStream.FileIOStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileIOStream.FileIOStream' or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileCreateReadwriteFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_create_readwrite_finish file' res'
        checkUnexpectedReturnNULL "fileCreateReadwriteFinish" result
        result' <- (wrapObject Gio.FileIOStream.FileIOStream) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileCreateReadwriteFinishMethodInfo
instance (signature ~ (b -> m Gio.FileIOStream.FileIOStream), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileCreateReadwriteFinishMethodInfo a signature where
    overloadedMethod _ = fileCreateReadwriteFinish

-- method File::delete
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_delete" g_file_delete :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Deletes a file. If the /@file@/ is a directory, it will only be
deleted if it is empty. This has the same semantics as 'GI.GLib.Functions.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileDelete ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileDelete file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_delete file' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data FileDeleteMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileDeleteMethodInfo a signature where
    overloadedMethod _ = fileDelete

-- method File::delete_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_delete_async" g_file_delete_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
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
'GI.GLib.Functions.unlink'.

@since 2.34
-}
fileDeleteAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileDeleteAsync file ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_delete_async file' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileDeleteAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileDeleteAsyncMethodInfo a signature where
    overloadedMethod _ = fileDeleteAsync

-- method File::delete_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_delete_finish" g_file_delete_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes deleting a file started with 'GI.Gio.Interfaces.File.fileDeleteAsync'.

@since 2.34
-}
fileDeleteFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileDeleteFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_delete_finish file' result_'
        touchManagedPtr file
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FileDeleteFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileDeleteFinishMethodInfo a signature where
    overloadedMethod _ = fileDeleteFinish

-- method File::dup
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_file_dup" g_file_dup :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO (Ptr File)

{- |
Duplicates a 'GI.Gio.Interfaces.File.File' handle. This operation does not duplicate
the actual file or directory represented by the 'GI.Gio.Interfaces.File.File'; see
'GI.Gio.Interfaces.File.fileCopy' if attempting to copy a file.

This call does no blocking I\/O.
-}
fileDup ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> m File
    {- ^ __Returns:__ a new 'GI.Gio.Interfaces.File.File' that is a duplicate
    of the given 'GI.Gio.Interfaces.File.File'. -}
fileDup file = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result <- g_file_dup file'
    checkUnexpectedReturnNULL "fileDup" result
    result' <- (wrapObject File) result
    touchManagedPtr file
    return result'

data FileDupMethodInfo
instance (signature ~ (m File), MonadIO m, IsFile a) => O.MethodInfo FileDupMethodInfo a signature where
    overloadedMethod _ = fileDup

-- method File::eject_mountable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the operation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_eject_mountable" g_file_eject_mountable :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{-# DEPRECATED fileEjectMountable ["(Since version 2.22)","Use 'GI.Gio.Interfaces.File.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
'GI.Gio.Interfaces.File.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileEjectMountable ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.MountUnmountFlags]
    {- ^ /@flags@/: flags affecting the operation -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied, or 'Nothing' -}
    -> m ()
fileEjectMountable file flags cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_eject_mountable file' flags' maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileEjectMountableMethodInfo
instance (signature ~ ([Gio.Flags.MountUnmountFlags] -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileEjectMountableMethodInfo a signature where
    overloadedMethod _ = fileEjectMountable

-- method File::eject_mountable_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_eject_mountable_finish" g_file_eject_mountable_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED fileEjectMountableFinish ["(Since version 2.22)","Use 'GI.Gio.Interfaces.File.fileEjectMountableWithOperationFinish'","    instead."] #-}
{- |
Finishes an asynchronous eject operation started by
'GI.Gio.Interfaces.File.fileEjectMountable'.
-}
fileEjectMountableFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileEjectMountableFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_eject_mountable_finish file' result_'
        touchManagedPtr file
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FileEjectMountableFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileEjectMountableFinishMethodInfo a signature where
    overloadedMethod _ = fileEjectMountableFinish

-- method File::eject_mountable_with_operation
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the operation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mount_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation,\n    or %NULL to avoid user interaction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_eject_mountable_with_operation" g_file_eject_mountable_with_operation :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- mount_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
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
'GI.Gio.Interfaces.File.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

@since 2.22
-}
fileEjectMountableWithOperation ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.MountUnmountFlags]
    {- ^ /@flags@/: flags affecting the operation -}
    -> Maybe (b)
    {- ^ /@mountOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation',
    or 'Nothing' to avoid user interaction -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied, or 'Nothing' -}
    -> m ()
fileEjectMountableWithOperation file flags mountOperation cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeMountOperation <- case mountOperation of
        Nothing -> return nullPtr
        Just jMountOperation -> do
            jMountOperation' <- unsafeManagedPtrCastPtr jMountOperation
            return jMountOperation'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_eject_mountable_with_operation file' flags' maybeMountOperation maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust mountOperation touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

data FileEjectMountableWithOperationMethodInfo
instance (signature ~ ([Gio.Flags.MountUnmountFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileEjectMountableWithOperationMethodInfo a signature where
    overloadedMethod _ = fileEjectMountableWithOperation

-- method File::eject_mountable_with_operation_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_eject_mountable_with_operation_finish" g_file_eject_mountable_with_operation_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes an asynchronous eject operation started by
'GI.Gio.Interfaces.File.fileEjectMountableWithOperation'.

@since 2.22
-}
fileEjectMountableWithOperationFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileEjectMountableWithOperationFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_eject_mountable_with_operation_finish file' result_'
        touchManagedPtr file
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FileEjectMountableWithOperationFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileEjectMountableWithOperationFinishMethodInfo a signature where
    overloadedMethod _ = fileEjectMountableWithOperationFinish

-- method File::enumerate_children
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attributes", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an attribute query string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileEnumerator"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_enumerate_children" g_file_enumerate_children :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attributes : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileEnumerator.FileEnumerator)

{- |
Gets the requested information about the files in a directory.
The result is a 'GI.Gio.Objects.FileEnumerator.FileEnumerator' object that will give out
'GI.Gio.Objects.FileInfo.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\".
The standard attributes are available as defines, like
'GI.Gio.Constants.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be
returned.

If the file does not exist, the 'GI.Gio.Enums.IOErrorEnumNotFound' error will
be returned. If the file is not a directory, the 'GI.Gio.Enums.IOErrorEnumNotDirectory'
error will be returned. Other errors are possible too.
-}
fileEnumerateChildren ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attributes@/: an attribute query string -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileEnumerator.FileEnumerator
    {- ^ __Returns:__ A 'GI.Gio.Objects.FileEnumerator.FileEnumerator' if successful,
    'Nothing' on error. Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileEnumerateChildren file attributes flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attributes' <- textToCString attributes
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_enumerate_children file' attributes' flags' maybeCancellable
        checkUnexpectedReturnNULL "fileEnumerateChildren" result
        result' <- (wrapObject Gio.FileEnumerator.FileEnumerator) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem attributes'
        return result'
     ) (do
        freeMem attributes'
     )

data FileEnumerateChildrenMethodInfo
instance (signature ~ (T.Text -> [Gio.Flags.FileQueryInfoFlags] -> Maybe (b) -> m Gio.FileEnumerator.FileEnumerator), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileEnumerateChildrenMethodInfo a signature where
    overloadedMethod _ = fileEnumerateChildren

-- method File::enumerate_children_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attributes", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an attribute query string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the\n    request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 6, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_enumerate_children_async" g_file_enumerate_children_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attributes : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously gets the requested information about the files
in a directory. The result is a 'GI.Gio.Objects.FileEnumerator.FileEnumerator' object that will
give out 'GI.Gio.Objects.FileInfo.FileInfo' objects for all the files in the directory.

For more details, see 'GI.Gio.Interfaces.File.fileEnumerateChildren' which is
the synchronous version of this call.

When the operation is finished, /@callback@/ will be called. You can
then call 'GI.Gio.Interfaces.File.fileEnumerateChildrenFinish' to get the result of
the operation.
-}
fileEnumerateChildrenAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attributes@/: an attribute query string -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the
    request is satisfied -}
    -> m ()
fileEnumerateChildrenAsync file attributes flags ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attributes' <- textToCString attributes
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_enumerate_children_async file' attributes' flags' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    freeMem attributes'
    return ()

data FileEnumerateChildrenAsyncMethodInfo
instance (signature ~ (T.Text -> [Gio.Flags.FileQueryInfoFlags] -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileEnumerateChildrenAsyncMethodInfo a signature where
    overloadedMethod _ = fileEnumerateChildrenAsync

-- method File::enumerate_children_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileEnumerator"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_enumerate_children_finish" g_file_enumerate_children_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileEnumerator.FileEnumerator)

{- |
Finishes an async enumerate children operation.
See 'GI.Gio.Interfaces.File.fileEnumerateChildrenAsync'.
-}
fileEnumerateChildrenFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.FileEnumerator.FileEnumerator
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileEnumerator.FileEnumerator' or 'Nothing'
    if an error occurred.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileEnumerateChildrenFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_enumerate_children_finish file' res'
        checkUnexpectedReturnNULL "fileEnumerateChildrenFinish" result
        result' <- (wrapObject Gio.FileEnumerator.FileEnumerator) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileEnumerateChildrenFinishMethodInfo
instance (signature ~ (b -> m Gio.FileEnumerator.FileEnumerator), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileEnumerateChildrenFinishMethodInfo a signature where
    overloadedMethod _ = fileEnumerateChildrenFinish

-- method File::equal
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file1", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the first #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file2", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the second #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_equal" g_file_equal :: 
    Ptr File ->                             -- file1 : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr File ->                             -- file2 : TInterface (Name {namespace = "Gio", name = "File"})
    IO CInt

{- |
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.
-}
fileEqual ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, IsFile b) =>
    a
    {- ^ /@file1@/: the first 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@file2@/: the second 'GI.Gio.Interfaces.File.File' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@file1@/ and /@file2@/ are equal. -}
fileEqual file1 file2 = liftIO $ do
    file1' <- unsafeManagedPtrCastPtr file1
    file2' <- unsafeManagedPtrCastPtr file2
    result <- g_file_equal file1' file2'
    let result' = (/= 0) result
    touchManagedPtr file1
    touchManagedPtr file2
    return result'

data FileEqualMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsFile a, IsFile b) => O.MethodInfo FileEqualMethodInfo a signature where
    overloadedMethod _ = fileEqual

-- method File::find_enclosing_mount
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Mount"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_find_enclosing_mount" g_file_find_enclosing_mount :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.Mount.Mount)

{- |
Gets a 'GI.Gio.Interfaces.Mount.Mount' for the 'GI.Gio.Interfaces.File.File'.

If the 'GI.Gio.Structs.FileIface.FileIface' for /@file@/ does not have a mount (e.g.
possibly a remote share), /@error@/ will be set to 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileFindEnclosingMount ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.Mount.Mount
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.Mount.Mount' where the /@file@/ is located
    or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileFindEnclosingMount file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_find_enclosing_mount file' maybeCancellable
        checkUnexpectedReturnNULL "fileFindEnclosingMount" result
        result' <- (wrapObject Gio.Mount.Mount) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileFindEnclosingMountMethodInfo
instance (signature ~ (Maybe (b) -> m Gio.Mount.Mount), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileFindEnclosingMountMethodInfo a signature where
    overloadedMethod _ = fileFindEnclosingMount

-- method File::find_enclosing_mount_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_find_enclosing_mount_async" g_file_find_enclosing_mount_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously gets the mount for the file.

For more details, see 'GI.Gio.Interfaces.File.fileFindEnclosingMount' which is
the synchronous version of this call.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileFindEnclosingMountFinish' to
get the result of the operation.
-}
fileFindEnclosingMountAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: a 'GI.Gio.Interfaces.File.File' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileFindEnclosingMountAsync file ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_find_enclosing_mount_async file' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileFindEnclosingMountAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileFindEnclosingMountAsyncMethodInfo a signature where
    overloadedMethod _ = fileFindEnclosingMountAsync

-- method File::find_enclosing_mount_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Mount"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_find_enclosing_mount_finish" g_file_find_enclosing_mount_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.Mount.Mount)

{- |
Finishes an asynchronous find mount request.
See 'GI.Gio.Interfaces.File.fileFindEnclosingMountAsync'.
-}
fileFindEnclosingMountFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: a 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.Mount.Mount
    {- ^ __Returns:__ 'GI.Gio.Interfaces.Mount.Mount' for given /@file@/ or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileFindEnclosingMountFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_find_enclosing_mount_finish file' res'
        checkUnexpectedReturnNULL "fileFindEnclosingMountFinish" result
        result' <- (wrapObject Gio.Mount.Mount) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileFindEnclosingMountFinishMethodInfo
instance (signature ~ (b -> m Gio.Mount.Mount), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileFindEnclosingMountFinishMethodInfo a signature where
    overloadedMethod _ = fileFindEnclosingMountFinish

-- method File::get_basename
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_get_basename" g_file_get_basename :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO CString

{- |
Gets the base name (the last component of the path) for a given 'GI.Gio.Interfaces.File.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 'GI.Gio.Constants.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME'
attribute with 'GI.Gio.Interfaces.File.fileQueryInfo'.

This call does no blocking I\/O.
-}
fileGetBasename ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> m (Maybe [Char])
    {- ^ __Returns:__ string containing the 'GI.Gio.Interfaces.File.File'\'s
    base name, or 'Nothing' if given 'GI.Gio.Interfaces.File.File' is invalid. The returned string
    should be freed with 'GI.GLib.Functions.free' when no longer needed. -}
fileGetBasename file = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result <- g_file_get_basename file'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToString result'
        freeMem result'
        return result''
    touchManagedPtr file
    return maybeResult

data FileGetBasenameMethodInfo
instance (signature ~ (m (Maybe [Char])), MonadIO m, IsFile a) => O.MethodInfo FileGetBasenameMethodInfo a signature where
    overloadedMethod _ = fileGetBasename

-- method File::get_child
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string containing the child's basename", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_file_get_child" g_file_get_child :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- name : TBasicType TFileName
    IO (Ptr File)

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

This call does no blocking I\/O.
-}
fileGetChild ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Char]
    {- ^ /@name@/: string containing the child\'s basename -}
    -> m File
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.File.File' to a child specified by /@name@/.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
fileGetChild file name = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    name' <- stringToCString name
    result <- g_file_get_child file' name'
    checkUnexpectedReturnNULL "fileGetChild" result
    result' <- (wrapObject File) result
    touchManagedPtr file
    freeMem name'
    return result'

data FileGetChildMethodInfo
instance (signature ~ ([Char] -> m File), MonadIO m, IsFile a) => O.MethodInfo FileGetChildMethodInfo a signature where
    overloadedMethod _ = fileGetChild

-- method File::get_child_for_display_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "display_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string to a possible child", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_get_child_for_display_name" g_file_get_child_for_display_name :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- display_name : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr File)

{- |
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
'GI.Gio.Interfaces.File.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.
-}
fileGetChildForDisplayName ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@displayName@/: string to a possible child -}
    -> m File
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.File.File' to the specified child, or
    'Nothing' if the display name couldn\'t be converted.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileGetChildForDisplayName file displayName = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    displayName' <- textToCString displayName
    onException (do
        result <- propagateGError $ g_file_get_child_for_display_name file' displayName'
        checkUnexpectedReturnNULL "fileGetChildForDisplayName" result
        result' <- (wrapObject File) result
        touchManagedPtr file
        freeMem displayName'
        return result'
     ) (do
        freeMem displayName'
     )

data FileGetChildForDisplayNameMethodInfo
instance (signature ~ (T.Text -> m File), MonadIO m, IsFile a) => O.MethodInfo FileGetChildForDisplayNameMethodInfo a signature where
    overloadedMethod _ = fileGetChildForDisplayName

-- method File::get_parent
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_file_get_parent" g_file_get_parent :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO (Ptr File)

{- |
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.
-}
fileGetParent ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> m (Maybe File)
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.File.File' structure to the
    parent of the given 'GI.Gio.Interfaces.File.File' or 'Nothing' if there is no parent. Free
    the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
fileGetParent file = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result <- g_file_get_parent file'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject File) result'
        return result''
    touchManagedPtr file
    return maybeResult

data FileGetParentMethodInfo
instance (signature ~ (m (Maybe File)), MonadIO m, IsFile a) => O.MethodInfo FileGetParentMethodInfo a signature where
    overloadedMethod _ = fileGetParent

-- method File::get_parse_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_get_parse_name" g_file_get_parse_name :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO CString

{- |
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 'GI.Gio.Interfaces.File.File' back using
'GI.Gio.Functions.fileParseName'.

This is generally used to show the 'GI.Gio.Interfaces.File.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.
-}
fileGetParseName ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> m T.Text
    {- ^ __Returns:__ a string containing the 'GI.Gio.Interfaces.File.File'\'s parse name.
    The returned string should be freed with 'GI.GLib.Functions.free'
    when no longer needed. -}
fileGetParseName file = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result <- g_file_get_parse_name file'
    checkUnexpectedReturnNULL "fileGetParseName" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr file
    return result'

data FileGetParseNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsFile a) => O.MethodInfo FileGetParseNameMethodInfo a signature where
    overloadedMethod _ = fileGetParseName

-- method File::get_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_get_path" g_file_get_path :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO CString

{- |
Gets the local pathname for 'GI.Gio.Interfaces.File.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.
-}
fileGetPath ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> m (Maybe [Char])
    {- ^ __Returns:__ string containing the 'GI.Gio.Interfaces.File.File'\'s path,
    or 'Nothing' if no such path exists. The returned string should be freed
    with 'GI.GLib.Functions.free' when no longer needed. -}
fileGetPath file = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result <- g_file_get_path file'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToString result'
        freeMem result'
        return result''
    touchManagedPtr file
    return maybeResult

data FileGetPathMethodInfo
instance (signature ~ (m (Maybe [Char])), MonadIO m, IsFile a) => O.MethodInfo FileGetPathMethodInfo a signature where
    overloadedMethod _ = fileGetPath

-- method File::get_relative_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "parent", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "descendant", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_get_relative_path" g_file_get_relative_path :: 
    Ptr File ->                             -- parent : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr File ->                             -- descendant : TInterface (Name {namespace = "Gio", name = "File"})
    IO CString

{- |
Gets the path for /@descendant@/ relative to /@parent@/.

This call does no blocking I\/O.
-}
fileGetRelativePath ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, IsFile b) =>
    a
    {- ^ /@parent@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@descendant@/: input 'GI.Gio.Interfaces.File.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 'GI.GLib.Functions.free' when
    no longer needed. -}
fileGetRelativePath parent descendant = liftIO $ do
    parent' <- unsafeManagedPtrCastPtr parent
    descendant' <- unsafeManagedPtrCastPtr descendant
    result <- g_file_get_relative_path parent' descendant'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToString result'
        freeMem result'
        return result''
    touchManagedPtr parent
    touchManagedPtr descendant
    return maybeResult

data FileGetRelativePathMethodInfo
instance (signature ~ (b -> m (Maybe [Char])), MonadIO m, IsFile a, IsFile b) => O.MethodInfo FileGetRelativePathMethodInfo a signature where
    overloadedMethod _ = fileGetRelativePath

-- method File::get_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_get_uri" g_file_get_uri :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO CString

{- |
Gets the URI for the /@file@/.

This call does no blocking I\/O.
-}
fileGetUri ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> m T.Text
    {- ^ __Returns:__ a string containing the 'GI.Gio.Interfaces.File.File'\'s URI.
    The returned string should be freed with 'GI.GLib.Functions.free'
    when no longer needed. -}
fileGetUri file = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result <- g_file_get_uri file'
    checkUnexpectedReturnNULL "fileGetUri" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr file
    return result'

data FileGetUriMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsFile a) => O.MethodInfo FileGetUriMethodInfo a signature where
    overloadedMethod _ = fileGetUri

-- method File::get_uri_scheme
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_get_uri_scheme" g_file_get_uri_scheme :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO CString

{- |
Gets the URI scheme for a 'GI.Gio.Interfaces.File.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.
-}
fileGetUriScheme ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> m T.Text
    {- ^ __Returns:__ a string containing the URI scheme for the given
    'GI.Gio.Interfaces.File.File'. The returned string should be freed with 'GI.GLib.Functions.free'
    when no longer needed. -}
fileGetUriScheme file = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result <- g_file_get_uri_scheme file'
    checkUnexpectedReturnNULL "fileGetUriScheme" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr file
    return result'

data FileGetUriSchemeMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsFile a) => O.MethodInfo FileGetUriSchemeMethodInfo a signature where
    overloadedMethod _ = fileGetUriScheme

-- method File::has_parent
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parent", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the parent to check for, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_has_parent" g_file_has_parent :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr File ->                             -- parent : TInterface (Name {namespace = "Gio", name = "File"})
    IO CInt

{- |
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
-}
fileHasParent ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, IsFile b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.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'). -}
fileHasParent file parent = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeParent <- case parent of
        Nothing -> return nullPtr
        Just jParent -> do
            jParent' <- unsafeManagedPtrCastPtr jParent
            return jParent'
    result <- g_file_has_parent file' maybeParent
    let result' = (/= 0) result
    touchManagedPtr file
    whenJust parent touchManagedPtr
    return result'

data FileHasParentMethodInfo
instance (signature ~ (Maybe (b) -> m Bool), MonadIO m, IsFile a, IsFile b) => O.MethodInfo FileHasParentMethodInfo a signature where
    overloadedMethod _ = fileHasParent

-- method File::has_prefix
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "prefix", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_has_prefix" g_file_has_prefix :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr File ->                             -- prefix : TInterface (Name {namespace = "Gio", name = "File"})
    IO CInt

{- |
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 'GI.Gio.Interfaces.File.File' is not a prefix of itself. If you want to check for
equality, use 'GI.Gio.Interfaces.File.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@/.
-}
fileHasPrefix ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, IsFile b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@prefix@/: input 'GI.Gio.Interfaces.File.File' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@files@/\'s parent, grandparent, etc is /@prefix@/,
    'False' otherwise. -}
fileHasPrefix file prefix = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    prefix' <- unsafeManagedPtrCastPtr prefix
    result <- g_file_has_prefix file' prefix'
    let result' = (/= 0) result
    touchManagedPtr file
    touchManagedPtr prefix
    return result'

data FileHasPrefixMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsFile a, IsFile b) => O.MethodInfo FileHasPrefixMethodInfo a signature where
    overloadedMethod _ = fileHasPrefix

-- method File::has_uri_scheme
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "uri_scheme", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing a URI scheme", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_has_uri_scheme" g_file_has_uri_scheme :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- uri_scheme : TBasicType TUTF8
    IO CInt

{- |
Checks to see if a 'GI.Gio.Interfaces.File.File' has a given URI scheme.

This call does no blocking I\/O.
-}
fileHasUriScheme ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@uriScheme@/: a string containing a URI scheme -}
    -> m Bool
    {- ^ __Returns:__ 'True' if 'GI.Gio.Interfaces.File.File'\'s backend supports the
    given URI scheme, 'False' if URI scheme is 'Nothing',
    not supported, or 'GI.Gio.Interfaces.File.File' is invalid. -}
fileHasUriScheme file uriScheme = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    uriScheme' <- textToCString uriScheme
    result <- g_file_has_uri_scheme file' uriScheme'
    let result' = (/= 0) result
    touchManagedPtr file
    freeMem uriScheme'
    return result'

data FileHasUriSchemeMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m, IsFile a) => O.MethodInfo FileHasUriSchemeMethodInfo a signature where
    overloadedMethod _ = fileHasUriScheme

-- method File::hash
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#gconstpointer to a #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_hash" g_file_hash :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO Word32

{- |
Creates a hash value for a 'GI.Gio.Interfaces.File.File'.

This call does no blocking I\/O.
-}
fileHash ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: @/gconstpointer/@ to a 'GI.Gio.Interfaces.File.File' -}
    -> m Word32
    {- ^ __Returns:__ 0 if /@file@/ is not a valid 'GI.Gio.Interfaces.File.File', otherwise an
    integer that can be used as hash value for the 'GI.Gio.Interfaces.File.File'.
    This function is intended for easily hashing a 'GI.Gio.Interfaces.File.File' to
    add to a 'GI.GLib.Structs.HashTable.HashTable' or similar data structure. -}
fileHash file = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result <- g_file_hash file'
    touchManagedPtr file
    return result

data FileHashMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsFile a) => O.MethodInfo FileHashMethodInfo a signature where
    overloadedMethod _ = fileHash

-- method File::is_native
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_is_native" g_file_is_native :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO CInt

{- |
Checks to see if a file is native to the platform.

A native file s 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 'GI.Gio.Interfaces.File.fileGetPath' will still return a native path.

This call does no blocking I\/O.
-}
fileIsNative ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@file@/ is native -}
fileIsNative file = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result <- g_file_is_native file'
    let result' = (/= 0) result
    touchManagedPtr file
    return result'

data FileIsNativeMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsFile a) => O.MethodInfo FileIsNativeMethodInfo a signature where
    overloadedMethod _ = fileIsNative

-- method File::load_contents
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "contents", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the contents of the file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the length of the contents of the file,\n   or %NULL if the length is not needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "etag_out", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the current entity tag for the file,\n   or %NULL if the entity tag is not needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the length of the contents of the file,\n   or %NULL if the length is not needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_load_contents" g_file_load_contents :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr Word8) ->                      -- contents : TCArray False (-1) 3 (TBasicType TUInt8)
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr CString ->                          -- etag_out : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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 'GI.GLib.Functions.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileLoadContents ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> m (ByteString,T.Text)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileLoadContents file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    contents <- allocMem :: IO (Ptr (Ptr Word8))
    length_ <- allocMem :: IO (Ptr Word64)
    etagOut <- allocMem :: IO (Ptr CString)
    onException (do
        _ <- propagateGError $ g_file_load_contents file' maybeCancellable contents length_ etagOut
        length_' <- peek length_
        contents' <- peek contents
        contents'' <- (unpackByteStringWithLength length_') contents'
        freeMem contents'
        etagOut' <- peek etagOut
        etagOut'' <- cstringToText etagOut'
        freeMem etagOut'
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem contents
        freeMem length_
        freeMem etagOut
        return (contents'', etagOut'')
     ) (do
        freeMem contents
        freeMem length_
        freeMem etagOut
     )

data FileLoadContentsMethodInfo
instance (signature ~ (Maybe (b) -> m (ByteString,T.Text)), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileLoadContentsMethodInfo a signature where
    overloadedMethod _ = fileLoadContents

-- method File::load_contents_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_load_contents_async" g_file_load_contents_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Starts an asynchronous load of the /@file@/\'s contents.

For more details, see 'GI.Gio.Interfaces.File.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
'GI.Gio.Interfaces.File.fileLoadContentsFinish' with the 'GI.Gio.Interfaces.AsyncResult.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileLoadContentsAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the request is satisfied -}
    -> m ()
fileLoadContentsAsync file cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_load_contents_async file' maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileLoadContentsAsyncMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileLoadContentsAsyncMethodInfo a signature where
    overloadedMethod _ = fileLoadContentsAsync

-- method File::load_contents_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "contents", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the contents of the file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the length of the contents of the file,\n    or %NULL if the length is not needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "etag_out", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the current entity tag for the file,\n    or %NULL if the entity tag is not needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the length of the contents of the file,\n    or %NULL if the length is not needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_load_contents_finish" g_file_load_contents_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr Word8) ->                      -- contents : TCArray False (-1) 3 (TBasicType TUInt8)
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr CString ->                          -- etag_out : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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
'GI.GLib.Functions.free' when no longer needed. If /@etagOut@/ is present, it will be
set to the new entity tag for the /@file@/.
-}
fileLoadContentsFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m (ByteString,T.Text)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileLoadContentsFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    contents <- allocMem :: IO (Ptr (Ptr Word8))
    length_ <- allocMem :: IO (Ptr Word64)
    etagOut <- allocMem :: IO (Ptr CString)
    onException (do
        _ <- propagateGError $ g_file_load_contents_finish file' res' contents length_ etagOut
        length_' <- peek length_
        contents' <- peek contents
        contents'' <- (unpackByteStringWithLength length_') contents'
        freeMem contents'
        etagOut' <- peek etagOut
        etagOut'' <- cstringToText etagOut'
        freeMem etagOut'
        touchManagedPtr file
        touchManagedPtr res
        freeMem contents
        freeMem length_
        freeMem etagOut
        return (contents'', etagOut'')
     ) (do
        freeMem contents
        freeMem length_
        freeMem etagOut
     )

data FileLoadContentsFinishMethodInfo
instance (signature ~ (b -> m (ByteString,T.Text)), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileLoadContentsFinishMethodInfo a signature where
    overloadedMethod _ = fileLoadContentsFinish

-- method File::load_partial_contents_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "contents", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the contents of the file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the length of the contents of the file,\n    or %NULL if the length is not needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "etag_out", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the current entity tag for the file,\n    or %NULL if the entity tag is not needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to place the length of the contents of the file,\n    or %NULL if the length is not needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_load_partial_contents_finish" g_file_load_partial_contents_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr Word8) ->                      -- contents : TCArray False (-1) 3 (TBasicType TUInt8)
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr CString ->                          -- etag_out : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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 'GI.GLib.Functions.free' when no longer
needed.
-}
fileLoadPartialContentsFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m (ByteString,T.Text)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileLoadPartialContentsFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    contents <- allocMem :: IO (Ptr (Ptr Word8))
    length_ <- allocMem :: IO (Ptr Word64)
    etagOut <- allocMem :: IO (Ptr CString)
    onException (do
        _ <- propagateGError $ g_file_load_partial_contents_finish file' res' contents length_ etagOut
        length_' <- peek length_
        contents' <- peek contents
        contents'' <- (unpackByteStringWithLength length_') contents'
        freeMem contents'
        etagOut' <- peek etagOut
        etagOut'' <- cstringToText etagOut'
        freeMem etagOut'
        touchManagedPtr file
        touchManagedPtr res
        freeMem contents
        freeMem length_
        freeMem etagOut
        return (contents'', etagOut'')
     ) (do
        freeMem contents
        freeMem length_
        freeMem etagOut
     )

data FileLoadPartialContentsFinishMethodInfo
instance (signature ~ (b -> m (ByteString,T.Text)), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileLoadPartialContentsFinishMethodInfo a signature where
    overloadedMethod _ = fileLoadPartialContentsFinish

-- method File::make_directory
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_make_directory" g_file_make_directory :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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 'GI.Gio.Interfaces.File.File'.
To recursively create directories, see 'GI.Gio.Interfaces.File.fileMakeDirectoryWithParents'.
This function will fail if the parent directory does not exist, setting
/@error@/ to 'GI.Gio.Enums.IOErrorEnumNotFound'. If the file system doesn\'t support
creating directories, this function will fail, setting /@error@/ to
'GI.Gio.Enums.IOErrorEnumNotSupported'.

For a local 'GI.Gio.Interfaces.File.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileMakeDirectory ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMakeDirectory file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_make_directory file' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data FileMakeDirectoryMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileMakeDirectoryMethodInfo a signature where
    overloadedMethod _ = fileMakeDirectory

-- method File::make_directory_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_make_directory_async" g_file_make_directory_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously creates a directory.

@since 2.38
-}
fileMakeDirectoryAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileMakeDirectoryAsync file ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_make_directory_async file' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileMakeDirectoryAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileMakeDirectoryAsyncMethodInfo a signature where
    overloadedMethod _ = fileMakeDirectoryAsync

-- method File::make_directory_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_make_directory_finish" g_file_make_directory_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes an asynchronous directory creation, started with
'GI.Gio.Interfaces.File.fileMakeDirectoryAsync'.

@since 2.38
-}
fileMakeDirectoryFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMakeDirectoryFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_make_directory_finish file' result_'
        touchManagedPtr file
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FileMakeDirectoryFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileMakeDirectoryFinishMethodInfo a signature where
    overloadedMethod _ = fileMakeDirectoryFinish

-- method File::make_directory_with_parents
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_make_directory_with_parents" g_file_make_directory_with_parents :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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
'GI.Gio.Enums.IOErrorEnumNotSupported'. If the directory itself already exists,
this function will fail setting /@error@/ to 'GI.Gio.Enums.IOErrorEnumExists', unlike
the similar 'GI.GLib.Functions.mkdirWithParents'.

For a local 'GI.Gio.Interfaces.File.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

@since 2.18
-}
fileMakeDirectoryWithParents ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMakeDirectoryWithParents file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_make_directory_with_parents file' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data FileMakeDirectoryWithParentsMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileMakeDirectoryWithParentsMethodInfo a signature where
    overloadedMethod _ = fileMakeDirectoryWithParents

-- method File::make_symbolic_link
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFile with the name of the symlink to create", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "symlink_value", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string with the path for the target\n    of the new symlink", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_make_symbolic_link" g_file_make_symbolic_link :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- symlink_value : TBasicType TFileName
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileMakeSymbolicLink ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: a 'GI.Gio.Interfaces.File.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 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMakeSymbolicLink file symlinkValue cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    symlinkValue' <- stringToCString symlinkValue
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_make_symbolic_link file' symlinkValue' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem symlinkValue'
        return ()
     ) (do
        freeMem symlinkValue'
     )

data FileMakeSymbolicLinkMethodInfo
instance (signature ~ ([Char] -> Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileMakeSymbolicLinkMethodInfo a signature where
    overloadedMethod _ = fileMakeSymbolicLink

-- method File::measure_disk_usage_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GAsyncResult passed to your #GAsyncReadyCallback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "disk_usage", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes of disk space used", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "num_dirs", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of directories encountered", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "num_files", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of non-directories encountered", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_measure_disk_usage_finish" g_file_measure_disk_usage_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Word64 ->                           -- disk_usage : TBasicType TUInt64
    Ptr Word64 ->                           -- num_dirs : TBasicType TUInt64
    Ptr Word64 ->                           -- num_files : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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
-}
fileMeasureDiskUsageFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: a 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: the 'GI.Gio.Interfaces.AsyncResult.AsyncResult' passed to your 'GI.Gio.Callbacks.AsyncReadyCallback' -}
    -> m (Word64,Word64,Word64)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMeasureDiskUsageFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    diskUsage <- allocMem :: IO (Ptr Word64)
    numDirs <- allocMem :: IO (Ptr Word64)
    numFiles <- allocMem :: IO (Ptr Word64)
    onException (do
        _ <- propagateGError $ g_file_measure_disk_usage_finish file' result_' diskUsage numDirs numFiles
        diskUsage' <- peek diskUsage
        numDirs' <- peek numDirs
        numFiles' <- peek numFiles
        touchManagedPtr file
        touchManagedPtr result_
        freeMem diskUsage
        freeMem numDirs
        freeMem numFiles
        return (diskUsage', numDirs', numFiles')
     ) (do
        freeMem diskUsage
        freeMem numDirs
        freeMem numFiles
     )

data FileMeasureDiskUsageFinishMethodInfo
instance (signature ~ (b -> m (Word64,Word64,Word64)), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileMeasureDiskUsageFinishMethodInfo a signature where
    overloadedMethod _ = fileMeasureDiskUsageFinish

-- method File::monitor
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileMonitorFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileMonitorFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileMonitor"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_monitor" g_file_monitor :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileMonitorFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileMonitor.FileMonitor)

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

@since 2.18
-}
fileMonitor ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileMonitorFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileMonitorFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileMonitor.FileMonitor
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileMonitor.FileMonitor' for the given /@file@/,
    or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMonitor file flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_monitor file' flags' maybeCancellable
        checkUnexpectedReturnNULL "fileMonitor" result
        result' <- (wrapObject Gio.FileMonitor.FileMonitor) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileMonitorMethodInfo
instance (signature ~ ([Gio.Flags.FileMonitorFlags] -> Maybe (b) -> m Gio.FileMonitor.FileMonitor), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileMonitorMethodInfo a signature where
    overloadedMethod _ = fileMonitor

-- method File::monitor_directory
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileMonitorFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileMonitorFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileMonitor"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_monitor_directory" g_file_monitor_directory :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileMonitorFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileMonitor.FileMonitor)

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

It does not make sense for /@flags@/ to contain
'GI.Gio.Flags.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 'GI.Gio.Interfaces.File.fileMonitor'.
-}
fileMonitorDirectory ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileMonitorFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileMonitorFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileMonitor.FileMonitor
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileMonitor.FileMonitor' for the given /@file@/,
    or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMonitorDirectory file flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_monitor_directory file' flags' maybeCancellable
        checkUnexpectedReturnNULL "fileMonitorDirectory" result
        result' <- (wrapObject Gio.FileMonitor.FileMonitor) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileMonitorDirectoryMethodInfo
instance (signature ~ ([Gio.Flags.FileMonitorFlags] -> Maybe (b) -> m Gio.FileMonitor.FileMonitor), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileMonitorDirectoryMethodInfo a signature where
    overloadedMethod _ = fileMonitorDirectory

-- method File::monitor_file
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileMonitorFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileMonitorFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileMonitor"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_monitor_file" g_file_monitor_file :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileMonitorFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileMonitor.FileMonitor)

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

If /@flags@/ contains 'GI.Gio.Flags.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 'GI.Gio.Objects.FileMonitor.FileMonitor'
backend and\/or filesystem type.
-}
fileMonitorFile ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileMonitorFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileMonitorFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileMonitor.FileMonitor
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileMonitor.FileMonitor' for the given /@file@/,
    or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMonitorFile file flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_monitor_file file' flags' maybeCancellable
        checkUnexpectedReturnNULL "fileMonitorFile" result
        result' <- (wrapObject Gio.FileMonitor.FileMonitor) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileMonitorFileMethodInfo
instance (signature ~ ([Gio.Flags.FileMonitorFlags] -> Maybe (b) -> m Gio.FileMonitor.FileMonitor), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileMonitorFileMethodInfo a signature where
    overloadedMethod _ = fileMonitorFile

-- method File::mount_enclosing_volume
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "location", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountMountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the operation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mount_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation\n    or %NULL to avoid user interaction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_mount_enclosing_volume" g_file_mount_enclosing_volume :: 
    Ptr File ->                             -- location : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountMountFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- mount_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
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
'GI.Gio.Interfaces.File.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileMountEnclosingVolume ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@location@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.MountMountFlags]
    {- ^ /@flags@/: flags affecting the operation -}
    -> Maybe (b)
    {- ^ /@mountOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation'
    or 'Nothing' to avoid user interaction -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied, or 'Nothing' -}
    -> m ()
fileMountEnclosingVolume location flags mountOperation cancellable callback = liftIO $ do
    location' <- unsafeManagedPtrCastPtr location
    let flags' = gflagsToWord flags
    maybeMountOperation <- case mountOperation of
        Nothing -> return nullPtr
        Just jMountOperation -> do
            jMountOperation' <- unsafeManagedPtrCastPtr jMountOperation
            return jMountOperation'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_mount_enclosing_volume location' flags' maybeMountOperation maybeCancellable maybeCallback userData
    touchManagedPtr location
    whenJust mountOperation touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

data FileMountEnclosingVolumeMethodInfo
instance (signature ~ ([Gio.Flags.MountMountFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileMountEnclosingVolumeMethodInfo a signature where
    overloadedMethod _ = fileMountEnclosingVolume

-- method File::mount_enclosing_volume_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "location", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_mount_enclosing_volume_finish" g_file_mount_enclosing_volume_finish :: 
    Ptr File ->                             -- location : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes a mount operation started by 'GI.Gio.Interfaces.File.fileMountEnclosingVolume'.
-}
fileMountEnclosingVolumeFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@location@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMountEnclosingVolumeFinish location result_ = liftIO $ do
    location' <- unsafeManagedPtrCastPtr location
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_mount_enclosing_volume_finish location' result_'
        touchManagedPtr location
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FileMountEnclosingVolumeFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileMountEnclosingVolumeFinishMethodInfo a signature where
    overloadedMethod _ = fileMountEnclosingVolumeFinish

-- method File::mount_mountable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountMountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the operation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mount_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation,\n    or %NULL to avoid user interaction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_mount_mountable" g_file_mount_mountable :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountMountFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- mount_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileMountMountableFinish' to get
the result of the operation.
-}
fileMountMountable ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.MountMountFlags]
    {- ^ /@flags@/: flags affecting the operation -}
    -> Maybe (b)
    {- ^ /@mountOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation',
    or 'Nothing' to avoid user interaction -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied, or 'Nothing' -}
    -> m ()
fileMountMountable file flags mountOperation cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeMountOperation <- case mountOperation of
        Nothing -> return nullPtr
        Just jMountOperation -> do
            jMountOperation' <- unsafeManagedPtrCastPtr jMountOperation
            return jMountOperation'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_mount_mountable file' flags' maybeMountOperation maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust mountOperation touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

data FileMountMountableMethodInfo
instance (signature ~ ([Gio.Flags.MountMountFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileMountMountableMethodInfo a signature where
    overloadedMethod _ = fileMountMountable

-- method File::mount_mountable_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_mount_mountable_finish" g_file_mount_mountable_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr File)

{- |
Finishes a mount operation. See 'GI.Gio.Interfaces.File.fileMountMountable' for details.

Finish an asynchronous mount operation that was started
with 'GI.Gio.Interfaces.File.fileMountMountable'.
-}
fileMountMountableFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m File
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.File.File' or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMountMountableFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_file_mount_mountable_finish file' result_'
        checkUnexpectedReturnNULL "fileMountMountableFinish" result
        result' <- (wrapObject File) result
        touchManagedPtr file
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )

data FileMountMountableFinishMethodInfo
instance (signature ~ (b -> m File), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileMountMountableFinishMethodInfo a signature where
    overloadedMethod _ = fileMountMountableFinish

-- method File::move
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GFile pointing to the source location", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destination", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GFile pointing to the destination location", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCopyFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "set of #GFileCopyFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "progress_callback", argType = TInterface (Name {namespace = "Gio", name = "FileProgressCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "#GFileProgressCallback\n    function for updates", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "progress_callback_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "gpointer to user data for\n    the callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_move" g_file_move :: 
    Ptr File ->                             -- source : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr File ->                             -- destination : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCopyFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_FileProgressCallback -> -- progress_callback : TInterface (Name {namespace = "Gio", name = "FileProgressCallback"})
    Ptr () ->                               -- progress_callback_data : TBasicType TPtr
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

If /@progressCallback@/ is not 'Nothing', then the operation can be monitored
by setting this to a 'GI.Gio.Callbacks.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 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumExists' is returned.

If trying to overwrite a file over a directory, the 'GI.Gio.Enums.IOErrorEnumIsDirectory'
error is returned. If trying to overwrite a directory with a directory the
'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumWouldRecurse' error may be returned (if the native
move operation isn\'t available).
-}
fileMove ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, IsFile b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@source@/: 'GI.Gio.Interfaces.File.File' pointing to the source location -}
    -> b
    {- ^ /@destination@/: 'GI.Gio.Interfaces.File.File' pointing to the destination location -}
    -> [Gio.Flags.FileCopyFlags]
    {- ^ /@flags@/: set of 'GI.Gio.Flags.FileCopyFlags' -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.FileProgressCallback)
    {- ^ /@progressCallback@/: 'GI.Gio.Callbacks.FileProgressCallback'
    function for updates -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileMove source destination flags cancellable progressCallback = liftIO $ do
    source' <- unsafeManagedPtrCastPtr source
    destination' <- unsafeManagedPtrCastPtr destination
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    maybeProgressCallback <- case progressCallback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jProgressCallback -> do
            jProgressCallback' <- Gio.Callbacks.mk_FileProgressCallback (Gio.Callbacks.wrap_FileProgressCallback Nothing (Gio.Callbacks.drop_closures_FileProgressCallback jProgressCallback))
            return jProgressCallback'
    let progressCallbackData = nullPtr
    onException (do
        _ <- propagateGError $ g_file_move source' destination' flags' maybeCancellable maybeProgressCallback progressCallbackData
        safeFreeFunPtr $ castFunPtrToPtr maybeProgressCallback
        touchManagedPtr source
        touchManagedPtr destination
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        safeFreeFunPtr $ castFunPtrToPtr maybeProgressCallback
        return ()
     )

data FileMoveMethodInfo
instance (signature ~ (b -> [Gio.Flags.FileCopyFlags] -> Maybe (c) -> Maybe (Gio.Callbacks.FileProgressCallback) -> m ()), MonadIO m, IsFile a, IsFile b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileMoveMethodInfo a signature where
    overloadedMethod _ = fileMove

-- method File::open_readwrite
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GFile to open", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileIOStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_open_readwrite" g_file_open_readwrite :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileIOStream.FileIOStream)

{- |
Opens an existing file for reading and writing. The result is
a 'GI.Gio.Objects.FileIOStream.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be
returned.

If the file does not exist, the 'GI.Gio.Enums.IOErrorEnumNotFound' error will
be returned. If the file is a directory, the 'GI.Gio.Enums.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
-}
fileOpenReadwrite ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: 'GI.Gio.Interfaces.File.File' to open -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' -}
    -> m Gio.FileIOStream.FileIOStream
    {- ^ __Returns:__ 'GI.Gio.Objects.FileIOStream.FileIOStream' or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileOpenReadwrite file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_open_readwrite file' maybeCancellable
        checkUnexpectedReturnNULL "fileOpenReadwrite" result
        result' <- (wrapObject Gio.FileIOStream.FileIOStream) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileOpenReadwriteMethodInfo
instance (signature ~ (Maybe (b) -> m Gio.FileIOStream.FileIOStream), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileOpenReadwriteMethodInfo a signature where
    overloadedMethod _ = fileOpenReadwrite

-- method File::open_readwrite_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_open_readwrite_async" g_file_open_readwrite_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously opens /@file@/ for reading and writing.

For more details, see 'GI.Gio.Interfaces.File.fileOpenReadwrite' which is
the synchronous version of this call.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileOpenReadwriteFinish' to get
the result of the operation.

@since 2.22
-}
fileOpenReadwriteAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileOpenReadwriteAsync file ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_open_readwrite_async file' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileOpenReadwriteAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileOpenReadwriteAsyncMethodInfo a signature where
    overloadedMethod _ = fileOpenReadwriteAsync

-- method File::open_readwrite_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileIOStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_open_readwrite_finish" g_file_open_readwrite_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileIOStream.FileIOStream)

{- |
Finishes an asynchronous file read operation started with
'GI.Gio.Interfaces.File.fileOpenReadwriteAsync'.

@since 2.22
-}
fileOpenReadwriteFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.FileIOStream.FileIOStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileIOStream.FileIOStream' or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileOpenReadwriteFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_open_readwrite_finish file' res'
        checkUnexpectedReturnNULL "fileOpenReadwriteFinish" result
        result' <- (wrapObject Gio.FileIOStream.FileIOStream) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileOpenReadwriteFinishMethodInfo
instance (signature ~ (b -> m Gio.FileIOStream.FileIOStream), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileOpenReadwriteFinishMethodInfo a signature where
    overloadedMethod _ = fileOpenReadwriteFinish

-- method File::poll_mountable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_poll_mountable" g_file_poll_mountable :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileMountMountableFinish' to get
the result of the operation.

@since 2.22
-}
filePollMountable ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied, or 'Nothing' -}
    -> m ()
filePollMountable file cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_poll_mountable file' maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FilePollMountableMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FilePollMountableMethodInfo a signature where
    overloadedMethod _ = filePollMountable

-- method File::poll_mountable_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_poll_mountable_finish" g_file_poll_mountable_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes a poll operation. See 'GI.Gio.Interfaces.File.filePollMountable' for details.

Finish an asynchronous poll operation that was polled
with 'GI.Gio.Interfaces.File.filePollMountable'.

@since 2.22
-}
filePollMountableFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
filePollMountableFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_poll_mountable_finish file' result_'
        touchManagedPtr file
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FilePollMountableFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FilePollMountableFinishMethodInfo a signature where
    overloadedMethod _ = filePollMountableFinish

-- method File::query_default_handler
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFile to open", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "AppInfo"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_query_default_handler" g_file_query_default_handler :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.AppInfo.AppInfo)

{- |
Returns the 'GI.Gio.Interfaces.AppInfo.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileQueryDefaultHandler ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: a 'GI.Gio.Interfaces.File.File' to open -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> m Gio.AppInfo.AppInfo
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.AppInfo.AppInfo' if the handle was found,
    'Nothing' if there were errors.
    When you are done with it, release it with 'GI.GObject.Objects.Object.objectUnref' /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileQueryDefaultHandler file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_query_default_handler file' maybeCancellable
        checkUnexpectedReturnNULL "fileQueryDefaultHandler" result
        result' <- (wrapObject Gio.AppInfo.AppInfo) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileQueryDefaultHandlerMethodInfo
instance (signature ~ (Maybe (b) -> m Gio.AppInfo.AppInfo), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileQueryDefaultHandlerMethodInfo a signature where
    overloadedMethod _ = fileQueryDefaultHandler

-- method File::query_exists
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_query_exists" g_file_query_exists :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    IO CInt

{- |
Utility function to check if a particular file exists. This is
implemented using 'GI.Gio.Interfaces.File.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 'GI.Gio.Interfaces.File.fileCreate' which will either
atomically create the file or fail with a 'GI.Gio.Enums.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.
-}
fileQueryExists ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the file exists (and can be detected without error),
    'False' otherwise (or if cancelled). -}
fileQueryExists file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    result <- g_file_query_exists file' maybeCancellable
    let result' = (/= 0) result
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return result'

data FileQueryExistsMethodInfo
instance (signature ~ (Maybe (b) -> m Bool), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileQueryExistsMethodInfo a signature where
    overloadedMethod _ = fileQueryExists

-- method File::query_file_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileQueryInfoFlags passed to g_file_query_info()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileType"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_file_query_file_type" g_file_query_file_type :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    IO CUInt

{- |
Utility function to inspect the 'GI.Gio.Enums.FileType' of a file. This is
implemented using 'GI.Gio.Interfaces.File.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
-}
fileQueryFileType ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileQueryInfoFlags' passed to 'GI.Gio.Interfaces.File.fileQueryInfo' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.Enums.FileType
    {- ^ __Returns:__ The 'GI.Gio.Enums.FileType' of the file and @/G_FILE_TYPE_UNKNOWN/@
    if the file does not exist -}
fileQueryFileType file flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    result <- g_file_query_file_type file' flags' maybeCancellable
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return result'

data FileQueryFileTypeMethodInfo
instance (signature ~ ([Gio.Flags.FileQueryInfoFlags] -> Maybe (b) -> m Gio.Enums.FileType), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileQueryFileTypeMethodInfo a signature where
    overloadedMethod _ = fileQueryFileType

-- method File::query_filesystem_info
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attributes", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an attribute query string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileInfo"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_query_filesystem_info" g_file_query_filesystem_info :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attributes : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileInfo.FileInfo)

{- |
Similar to 'GI.Gio.Interfaces.File.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
'GI.Gio.Constants.FILE_ATTRIBUTE_FILESYSTEM_SIZE' (the total size of the filesystem
in bytes), 'GI.Gio.Constants.FILE_ATTRIBUTE_FILESYSTEM_FREE' (number of bytes available),
and 'GI.Gio.Constants.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be
returned.

If the file does not exist, the 'GI.Gio.Enums.IOErrorEnumNotFound' error will
be returned. Other errors are possible too, and depend on what
kind of filesystem the file is on.
-}
fileQueryFilesystemInfo ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attributes@/: an attribute query string -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileInfo.FileInfo
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileInfo.FileInfo' or 'Nothing' if there was an error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileQueryFilesystemInfo file attributes cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attributes' <- textToCString attributes
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_query_filesystem_info file' attributes' maybeCancellable
        checkUnexpectedReturnNULL "fileQueryFilesystemInfo" result
        result' <- (wrapObject Gio.FileInfo.FileInfo) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem attributes'
        return result'
     ) (do
        freeMem attributes'
     )

data FileQueryFilesystemInfoMethodInfo
instance (signature ~ (T.Text -> Maybe (b) -> m Gio.FileInfo.FileInfo), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileQueryFilesystemInfoMethodInfo a signature where
    overloadedMethod _ = fileQueryFilesystemInfo

-- method File::query_filesystem_info_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attributes", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an attribute query string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_query_filesystem_info_async" g_file_query_filesystem_info_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attributes : TBasicType TUTF8
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously gets the requested information about the filesystem
that the specified /@file@/ is on. The result is a 'GI.Gio.Objects.FileInfo.FileInfo' object
that contains key-value attributes (such as type or size for the
file).

For more details, see 'GI.Gio.Interfaces.File.fileQueryFilesystemInfo' which is the
synchronous version of this call.

When the operation is finished, /@callback@/ will be called. You can
then call 'GI.Gio.Interfaces.File.fileQueryInfoFinish' to get the result of the
operation.
-}
fileQueryFilesystemInfoAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attributes@/: an attribute query string -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileQueryFilesystemInfoAsync file attributes ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attributes' <- textToCString attributes
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_query_filesystem_info_async file' attributes' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    freeMem attributes'
    return ()

data FileQueryFilesystemInfoAsyncMethodInfo
instance (signature ~ (T.Text -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileQueryFilesystemInfoAsyncMethodInfo a signature where
    overloadedMethod _ = fileQueryFilesystemInfoAsync

-- method File::query_filesystem_info_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileInfo"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_query_filesystem_info_finish" g_file_query_filesystem_info_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileInfo.FileInfo)

{- |
Finishes an asynchronous filesystem info query.
See 'GI.Gio.Interfaces.File.fileQueryFilesystemInfoAsync'.
-}
fileQueryFilesystemInfoFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.FileInfo.FileInfo
    {- ^ __Returns:__ 'GI.Gio.Objects.FileInfo.FileInfo' for given /@file@/
    or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileQueryFilesystemInfoFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_query_filesystem_info_finish file' res'
        checkUnexpectedReturnNULL "fileQueryFilesystemInfoFinish" result
        result' <- (wrapObject Gio.FileInfo.FileInfo) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileQueryFilesystemInfoFinishMethodInfo
instance (signature ~ (b -> m Gio.FileInfo.FileInfo), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileQueryFilesystemInfoFinishMethodInfo a signature where
    overloadedMethod _ = fileQueryFilesystemInfoFinish

-- method File::query_info
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attributes", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an attribute query string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileInfo"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_query_info" g_file_query_info :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attributes : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileInfo.FileInfo)

{- |
Gets the requested information about specified /@file@/.
The result is a 'GI.Gio.Objects.FileInfo.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\".
The standard attributes are available as defines, like
'GI.Gio.Constants.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 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumNotFound' error will be
returned. Other errors are possible too, and depend on what kind of
filesystem the file is on.
-}
fileQueryInfo ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attributes@/: an attribute query string -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileInfo.FileInfo
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileInfo.FileInfo' for the given /@file@/, or 'Nothing'
    on error. Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileQueryInfo file attributes flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attributes' <- textToCString attributes
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_query_info file' attributes' flags' maybeCancellable
        checkUnexpectedReturnNULL "fileQueryInfo" result
        result' <- (wrapObject Gio.FileInfo.FileInfo) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem attributes'
        return result'
     ) (do
        freeMem attributes'
     )

data FileQueryInfoMethodInfo
instance (signature ~ (T.Text -> [Gio.Flags.FileQueryInfoFlags] -> Maybe (b) -> m Gio.FileInfo.FileInfo), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileQueryInfoMethodInfo a signature where
    overloadedMethod _ = fileQueryInfo

-- method File::query_info_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attributes", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an attribute query string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the\n    request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 6, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_query_info_async" g_file_query_info_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attributes : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously gets the requested information about specified /@file@/.
The result is a 'GI.Gio.Objects.FileInfo.FileInfo' object that contains key-value attributes
(such as type or size for the file).

For more details, see 'GI.Gio.Interfaces.File.fileQueryInfo' which is the synchronous
version of this call.

When the operation is finished, /@callback@/ will be called. You can
then call 'GI.Gio.Interfaces.File.fileQueryInfoFinish' to get the result of the operation.
-}
fileQueryInfoAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attributes@/: an attribute query string -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the
    request is satisfied -}
    -> m ()
fileQueryInfoAsync file attributes flags ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attributes' <- textToCString attributes
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_query_info_async file' attributes' flags' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    freeMem attributes'
    return ()

data FileQueryInfoAsyncMethodInfo
instance (signature ~ (T.Text -> [Gio.Flags.FileQueryInfoFlags] -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileQueryInfoAsyncMethodInfo a signature where
    overloadedMethod _ = fileQueryInfoAsync

-- method File::query_info_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileInfo"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_query_info_finish" g_file_query_info_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileInfo.FileInfo)

{- |
Finishes an asynchronous file info query.
See 'GI.Gio.Interfaces.File.fileQueryInfoAsync'.
-}
fileQueryInfoFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.FileInfo.FileInfo
    {- ^ __Returns:__ 'GI.Gio.Objects.FileInfo.FileInfo' for given /@file@/
    or 'Nothing' on error. Free the returned object with
    'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileQueryInfoFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_query_info_finish file' res'
        checkUnexpectedReturnNULL "fileQueryInfoFinish" result
        result' <- (wrapObject Gio.FileInfo.FileInfo) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileQueryInfoFinishMethodInfo
instance (signature ~ (b -> m Gio.FileInfo.FileInfo), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileQueryInfoFinishMethodInfo a signature where
    overloadedMethod _ = fileQueryInfoFinish

-- method File::query_settable_attributes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileAttributeInfoList"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_query_settable_attributes" g_file_query_settable_attributes :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileAttributeInfoList.FileAttributeInfoList)

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileQuerySettableAttributes ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileAttributeInfoList.FileAttributeInfoList
    {- ^ __Returns:__ a 'GI.Gio.Structs.FileAttributeInfoList.FileAttributeInfoList' describing the settable attributes.
    When you are done with it, release it with
    'GI.Gio.Structs.FileAttributeInfoList.fileAttributeInfoListUnref' /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileQuerySettableAttributes file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_query_settable_attributes file' maybeCancellable
        checkUnexpectedReturnNULL "fileQuerySettableAttributes" result
        result' <- (wrapBoxed Gio.FileAttributeInfoList.FileAttributeInfoList) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileQuerySettableAttributesMethodInfo
instance (signature ~ (Maybe (b) -> m Gio.FileAttributeInfoList.FileAttributeInfoList), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileQuerySettableAttributesMethodInfo a signature where
    overloadedMethod _ = fileQuerySettableAttributes

-- method File::query_writable_namespaces
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileAttributeInfoList"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_query_writable_namespaces" g_file_query_writable_namespaces :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileAttributeInfoList.FileAttributeInfoList)

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileQueryWritableNamespaces ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileAttributeInfoList.FileAttributeInfoList
    {- ^ __Returns:__ a 'GI.Gio.Structs.FileAttributeInfoList.FileAttributeInfoList' describing the writable namespaces.
    When you are done with it, release it with
    'GI.Gio.Structs.FileAttributeInfoList.fileAttributeInfoListUnref' /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileQueryWritableNamespaces file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_query_writable_namespaces file' maybeCancellable
        checkUnexpectedReturnNULL "fileQueryWritableNamespaces" result
        result' <- (wrapBoxed Gio.FileAttributeInfoList.FileAttributeInfoList) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileQueryWritableNamespacesMethodInfo
instance (signature ~ (Maybe (b) -> m Gio.FileAttributeInfoList.FileAttributeInfoList), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileQueryWritableNamespacesMethodInfo a signature where
    overloadedMethod _ = fileQueryWritableNamespaces

-- method File::read
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GFile to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileInputStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_read" g_file_read :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileInputStream.FileInputStream)

{- |
Opens a file for reading. The result is a 'GI.Gio.Objects.FileInputStream.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

If the file does not exist, the 'GI.Gio.Enums.IOErrorEnumNotFound' error will be
returned. If the file is a directory, the 'GI.Gio.Enums.IOErrorEnumIsDirectory'
error will be returned. Other errors are possible too, and depend
on what kind of filesystem the file is on.
-}
fileRead ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: 'GI.Gio.Interfaces.File.File' to read -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' -}
    -> m Gio.FileInputStream.FileInputStream
    {- ^ __Returns:__ 'GI.Gio.Objects.FileInputStream.FileInputStream' or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileRead file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_read file' maybeCancellable
        checkUnexpectedReturnNULL "fileRead" result
        result' <- (wrapObject Gio.FileInputStream.FileInputStream) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

data FileReadMethodInfo
instance (signature ~ (Maybe (b) -> m Gio.FileInputStream.FileInputStream), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileReadMethodInfo a signature where
    overloadedMethod _ = fileRead

-- method File::read_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_read_async" g_file_read_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously opens /@file@/ for reading.

For more details, see 'GI.Gio.Interfaces.File.fileRead' which is
the synchronous version of this call.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileReadFinish' to get the result
of the operation.
-}
fileReadAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileReadAsync file ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_read_async file' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileReadAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileReadAsyncMethodInfo a signature where
    overloadedMethod _ = fileReadAsync

-- method File::read_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileInputStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_read_finish" g_file_read_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileInputStream.FileInputStream)

{- |
Finishes an asynchronous file read operation started with
'GI.Gio.Interfaces.File.fileReadAsync'.
-}
fileReadFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.FileInputStream.FileInputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileInputStream.FileInputStream' or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileReadFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_read_finish file' res'
        checkUnexpectedReturnNULL "fileReadFinish" result
        result' <- (wrapObject Gio.FileInputStream.FileInputStream) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileReadFinishMethodInfo
instance (signature ~ (b -> m Gio.FileInputStream.FileInputStream), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileReadFinishMethodInfo a signature where
    overloadedMethod _ = fileReadFinish

-- method File::replace
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "etag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an optional [entity tag][gfile-etag]\n    for the current #GFile, or #NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "make_backup", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if a backup should be created", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileOutputStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_replace" g_file_replace :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- etag : TBasicType TUTF8
    CInt ->                                 -- make_backup : TBasicType TBoolean
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileOutputStream.FileOutputStream)

{- |
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 'GI.Gio.Enums.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 'GI.Gio.Enums.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 'GI.Gio.Objects.FileOutputStream.fileOutputStreamGetEtag'
after you\'ve finished writing and closed the 'GI.Gio.Objects.FileOutputStream.FileOutputStream'. When
you load a new file you can use 'GI.Gio.Objects.FileInputStream.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 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumIsDirectory' error will
be returned, and if the file is some other form of non-regular file
then a 'GI.Gio.Enums.IOErrorEnumNotRegularFile' error will be returned. Some
file systems don\'t allow all file names, and may return an
'GI.Gio.Enums.IOErrorEnumInvalidFilename' error, and if the name is to long
'GI.Gio.Enums.IOErrorEnumFilenameTooLong' will be returned. Other errors are
possible too, and depend on what kind of filesystem the file is on.
-}
fileReplace ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (T.Text)
    {- ^ /@etag@/: an optional [entity tag][gfile-etag]
    for the current 'GI.Gio.Interfaces.File.File', or @/NULL/@ to ignore -}
    -> Bool
    {- ^ /@makeBackup@/: 'True' if a backup should be created -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileOutputStream.FileOutputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileOutputStream.FileOutputStream' or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileReplace file etag makeBackup flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeEtag <- case etag of
        Nothing -> return nullPtr
        Just jEtag -> do
            jEtag' <- textToCString jEtag
            return jEtag'
    let makeBackup' = (fromIntegral . fromEnum) makeBackup
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_replace file' maybeEtag makeBackup' flags' maybeCancellable
        checkUnexpectedReturnNULL "fileReplace" result
        result' <- (wrapObject Gio.FileOutputStream.FileOutputStream) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem maybeEtag
        return result'
     ) (do
        freeMem maybeEtag
     )

data FileReplaceMethodInfo
instance (signature ~ (Maybe (T.Text) -> Bool -> [Gio.Flags.FileCreateFlags] -> Maybe (b) -> m Gio.FileOutputStream.FileOutputStream), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileReplaceMethodInfo a signature where
    overloadedMethod _ = fileReplace

-- method File::replace_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "etag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an [entity tag][gfile-etag] for the current #GFile,\n    or %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "make_backup", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if a backup should be created", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 7, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_replace_async" g_file_replace_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- etag : TBasicType TUTF8
    CInt ->                                 -- make_backup : TBasicType TBoolean
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

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

For more details, see 'GI.Gio.Interfaces.File.fileReplace' which is
the synchronous version of this call.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileReplaceFinish' to get the result
of the operation.
-}
fileReplaceAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (T.Text)
    {- ^ /@etag@/: an [entity tag][gfile-etag] for the current 'GI.Gio.Interfaces.File.File',
    or 'Nothing' to ignore -}
    -> Bool
    {- ^ /@makeBackup@/: 'True' if a backup should be created -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileReplaceAsync file etag makeBackup flags ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeEtag <- case etag of
        Nothing -> return nullPtr
        Just jEtag -> do
            jEtag' <- textToCString jEtag
            return jEtag'
    let makeBackup' = (fromIntegral . fromEnum) makeBackup
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_replace_async file' maybeEtag makeBackup' flags' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    freeMem maybeEtag
    return ()

data FileReplaceAsyncMethodInfo
instance (signature ~ (Maybe (T.Text) -> Bool -> [Gio.Flags.FileCreateFlags] -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileReplaceAsyncMethodInfo a signature where
    overloadedMethod _ = fileReplaceAsync

-- method File::replace_contents
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "contents", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the new contents for @file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @contents in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "etag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the old [entity-tag][gfile-etag] for the document,\n    or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "make_backup", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if a backup should be created", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_etag", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to a new [entity tag][gfile-etag]\n     for the document. This should be freed with g_free() when no longer\n     needed, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @contents in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_replace_contents" g_file_replace_contents :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Word8 ->                            -- contents : TCArray False (-1) 2 (TBasicType TUInt8)
    Word64 ->                               -- length : TBasicType TUInt64
    CString ->                              -- etag : TBasicType TUTF8
    CInt ->                                 -- make_backup : TBasicType TBoolean
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Ptr CString ->                          -- new_etag : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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 'GI.Gio.Enums.IOErrorEnumWrongEtag' will be returned.

If /@makeBackup@/ is 'True', this function will attempt to make a backup
of /@file@/. Internally, it uses 'GI.Gio.Interfaces.File.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 'GI.Gio.Enums.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.
-}
fileReplaceContents ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> ByteString
    {- ^ /@contents@/: a string containing the new contents for /@file@/ -}
    -> Maybe (T.Text)
    {- ^ /@etag@/: the old [entity-tag][gfile-etag] for the document,
    or 'Nothing' -}
    -> Bool
    {- ^ /@makeBackup@/: 'True' if a backup should be created -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> m (T.Text)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileReplaceContents file contents etag makeBackup flags cancellable = liftIO $ do
    let length_ = fromIntegral $ B.length contents
    file' <- unsafeManagedPtrCastPtr file
    contents' <- packByteString contents
    maybeEtag <- case etag of
        Nothing -> return nullPtr
        Just jEtag -> do
            jEtag' <- textToCString jEtag
            return jEtag'
    let makeBackup' = (fromIntegral . fromEnum) makeBackup
    let flags' = gflagsToWord flags
    newEtag <- allocMem :: IO (Ptr CString)
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_replace_contents file' contents' length_ maybeEtag makeBackup' flags' newEtag maybeCancellable
        newEtag' <- peek newEtag
        newEtag'' <- cstringToText newEtag'
        freeMem newEtag'
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem contents'
        freeMem maybeEtag
        freeMem newEtag
        return newEtag''
     ) (do
        freeMem contents'
        freeMem maybeEtag
        freeMem newEtag
     )

data FileReplaceContentsMethodInfo
instance (signature ~ (ByteString -> Maybe (T.Text) -> Bool -> [Gio.Flags.FileCreateFlags] -> Maybe (b) -> m (T.Text)), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileReplaceContentsMethodInfo a signature where
    overloadedMethod _ = fileReplaceContents

-- method File::replace_contents_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "contents", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string of contents to replace the file with", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @contents in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "etag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a new [entity tag][gfile-etag] for the @file, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "make_backup", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if a backup should be created", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 8, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @contents in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_replace_contents_async" g_file_replace_contents_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Word8 ->                            -- contents : TCArray False (-1) 2 (TBasicType TUInt8)
    Word64 ->                               -- length : TBasicType TUInt64
    CString ->                              -- etag : TBasicType TUTF8
    CInt ->                                 -- make_backup : TBasicType TBoolean
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
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
'GI.Gio.Interfaces.File.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 'GI.Gio.Enums.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 'GI.Gio.Interfaces.File.fileReplaceContentsBytesAsync'
for a 'GI.GLib.Structs.Bytes.Bytes' version that will automatically hold a reference to the
contents (without copying) for the duration of the call.
-}
fileReplaceContentsAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> ByteString
    {- ^ /@contents@/: string of contents to replace the file with -}
    -> Maybe (T.Text)
    {- ^ /@etag@/: a new [entity tag][gfile-etag] for the /@file@/, or 'Nothing' -}
    -> Bool
    {- ^ /@makeBackup@/: 'True' if a backup should be created -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the request is satisfied -}
    -> m ()
fileReplaceContentsAsync file contents etag makeBackup flags cancellable callback = liftIO $ do
    let length_ = fromIntegral $ B.length contents
    file' <- unsafeManagedPtrCastPtr file
    contents' <- packByteString contents
    maybeEtag <- case etag of
        Nothing -> return nullPtr
        Just jEtag -> do
            jEtag' <- textToCString jEtag
            return jEtag'
    let makeBackup' = (fromIntegral . fromEnum) makeBackup
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_replace_contents_async file' contents' length_ maybeEtag makeBackup' flags' maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    freeMem contents'
    freeMem maybeEtag
    return ()

data FileReplaceContentsAsyncMethodInfo
instance (signature ~ (ByteString -> Maybe (T.Text) -> Bool -> [Gio.Flags.FileCreateFlags] -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileReplaceContentsAsyncMethodInfo a signature where
    overloadedMethod _ = fileReplaceContentsAsync

-- method File::replace_contents_bytes_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "contents", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "etag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a new [entity tag][gfile-etag] for the @file, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "make_backup", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if a backup should be created", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 7, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_replace_contents_bytes_async" g_file_replace_contents_bytes_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr GLib.Bytes.Bytes ->                 -- contents : TInterface (Name {namespace = "GLib", name = "Bytes"})
    CString ->                              -- etag : TBasicType TUTF8
    CInt ->                                 -- make_backup : TBasicType TBoolean
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Same as 'GI.Gio.Interfaces.File.fileReplaceContentsAsync' but takes a 'GI.GLib.Structs.Bytes.Bytes' input instead.
This function will keep a ref on /@contents@/ until the operation is done.
Unlike 'GI.Gio.Interfaces.File.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
'GI.Gio.Interfaces.File.fileReplaceContentsFinish'.

@since 2.40
-}
fileReplaceContentsBytesAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> GLib.Bytes.Bytes
    {- ^ /@contents@/: a 'GI.GLib.Structs.Bytes.Bytes' -}
    -> Maybe (T.Text)
    {- ^ /@etag@/: a new [entity tag][gfile-etag] for the /@file@/, or 'Nothing' -}
    -> Bool
    {- ^ /@makeBackup@/: 'True' if a backup should be created -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the request is satisfied -}
    -> m ()
fileReplaceContentsBytesAsync file contents etag makeBackup flags cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    contents' <- unsafeManagedPtrGetPtr contents
    maybeEtag <- case etag of
        Nothing -> return nullPtr
        Just jEtag -> do
            jEtag' <- textToCString jEtag
            return jEtag'
    let makeBackup' = (fromIntegral . fromEnum) makeBackup
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_replace_contents_bytes_async file' contents' maybeEtag makeBackup' flags' maybeCancellable maybeCallback userData
    touchManagedPtr file
    touchManagedPtr contents
    whenJust cancellable touchManagedPtr
    freeMem maybeEtag
    return ()

data FileReplaceContentsBytesAsyncMethodInfo
instance (signature ~ (GLib.Bytes.Bytes -> Maybe (T.Text) -> Bool -> [Gio.Flags.FileCreateFlags] -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileReplaceContentsBytesAsyncMethodInfo a signature where
    overloadedMethod _ = fileReplaceContentsBytesAsync

-- method File::replace_contents_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_etag", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location of a new [entity tag][gfile-etag]\n    for the document. This should be freed with g_free() when it is no\n    longer needed, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_replace_contents_finish" g_file_replace_contents_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr CString ->                          -- new_etag : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes an asynchronous replace of the given /@file@/. See
'GI.Gio.Interfaces.File.fileReplaceContentsAsync'. Sets /@newEtag@/ to the new entity
tag for the document, if present.
-}
fileReplaceContentsFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m (T.Text)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileReplaceContentsFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    newEtag <- allocMem :: IO (Ptr CString)
    onException (do
        _ <- propagateGError $ g_file_replace_contents_finish file' res' newEtag
        newEtag' <- peek newEtag
        newEtag'' <- cstringToText newEtag'
        freeMem newEtag'
        touchManagedPtr file
        touchManagedPtr res
        freeMem newEtag
        return newEtag''
     ) (do
        freeMem newEtag
     )

data FileReplaceContentsFinishMethodInfo
instance (signature ~ (b -> m (T.Text)), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileReplaceContentsFinishMethodInfo a signature where
    overloadedMethod _ = fileReplaceContentsFinish

-- method File::replace_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileOutputStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_replace_finish" g_file_replace_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileOutputStream.FileOutputStream)

{- |
Finishes an asynchronous file replace operation started with
'GI.Gio.Interfaces.File.fileReplaceAsync'.
-}
fileReplaceFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.FileOutputStream.FileOutputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileOutputStream.FileOutputStream', or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileReplaceFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_replace_finish file' res'
        checkUnexpectedReturnNULL "fileReplaceFinish" result
        result' <- (wrapObject Gio.FileOutputStream.FileOutputStream) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileReplaceFinishMethodInfo
instance (signature ~ (b -> m Gio.FileOutputStream.FileOutputStream), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileReplaceFinishMethodInfo a signature where
    overloadedMethod _ = fileReplaceFinish

-- method File::replace_readwrite
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "etag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an optional [entity tag][gfile-etag]\n    for the current #GFile, or #NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "make_backup", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if a backup should be created", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileIOStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_replace_readwrite" g_file_replace_readwrite :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- etag : TBasicType TUTF8
    CInt ->                                 -- make_backup : TBasicType TBoolean
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileIOStream.FileIOStream)

{- |
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 'GI.Gio.Interfaces.File.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
-}
fileReplaceReadwrite ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: a 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (T.Text)
    {- ^ /@etag@/: an optional [entity tag][gfile-etag]
    for the current 'GI.Gio.Interfaces.File.File', or @/NULL/@ to ignore -}
    -> Bool
    {- ^ /@makeBackup@/: 'True' if a backup should be created -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m Gio.FileIOStream.FileIOStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileIOStream.FileIOStream' or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileReplaceReadwrite file etag makeBackup flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeEtag <- case etag of
        Nothing -> return nullPtr
        Just jEtag -> do
            jEtag' <- textToCString jEtag
            return jEtag'
    let makeBackup' = (fromIntegral . fromEnum) makeBackup
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_replace_readwrite file' maybeEtag makeBackup' flags' maybeCancellable
        checkUnexpectedReturnNULL "fileReplaceReadwrite" result
        result' <- (wrapObject Gio.FileIOStream.FileIOStream) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem maybeEtag
        return result'
     ) (do
        freeMem maybeEtag
     )

data FileReplaceReadwriteMethodInfo
instance (signature ~ (Maybe (T.Text) -> Bool -> [Gio.Flags.FileCreateFlags] -> Maybe (b) -> m Gio.FileIOStream.FileIOStream), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileReplaceReadwriteMethodInfo a signature where
    overloadedMethod _ = fileReplaceReadwrite

-- method File::replace_readwrite_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "etag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an [entity tag][gfile-etag] for the current #GFile,\n    or %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "make_backup", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if a backup should be created", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileCreateFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 7, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_replace_readwrite_async" g_file_replace_readwrite_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- etag : TBasicType TUTF8
    CInt ->                                 -- make_backup : TBasicType TBoolean
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileCreateFlags"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

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

For more details, see 'GI.Gio.Interfaces.File.fileReplaceReadwrite' which is
the synchronous version of this call.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileReplaceReadwriteFinish' to get
the result of the operation.

@since 2.22
-}
fileReplaceReadwriteAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Maybe (T.Text)
    {- ^ /@etag@/: an [entity tag][gfile-etag] for the current 'GI.Gio.Interfaces.File.File',
    or 'Nothing' to ignore -}
    -> Bool
    {- ^ /@makeBackup@/: 'True' if a backup should be created -}
    -> [Gio.Flags.FileCreateFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileCreateFlags' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileReplaceReadwriteAsync file etag makeBackup flags ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeEtag <- case etag of
        Nothing -> return nullPtr
        Just jEtag -> do
            jEtag' <- textToCString jEtag
            return jEtag'
    let makeBackup' = (fromIntegral . fromEnum) makeBackup
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_replace_readwrite_async file' maybeEtag makeBackup' flags' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    freeMem maybeEtag
    return ()

data FileReplaceReadwriteAsyncMethodInfo
instance (signature ~ (Maybe (T.Text) -> Bool -> [Gio.Flags.FileCreateFlags] -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileReplaceReadwriteAsyncMethodInfo a signature where
    overloadedMethod _ = fileReplaceReadwriteAsync

-- method File::replace_readwrite_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "FileIOStream"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_replace_readwrite_finish" g_file_replace_readwrite_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileIOStream.FileIOStream)

{- |
Finishes an asynchronous file replace operation started with
'GI.Gio.Interfaces.File.fileReplaceReadwriteAsync'.

@since 2.22
-}
fileReplaceReadwriteFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Gio.FileIOStream.FileIOStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.FileIOStream.FileIOStream', or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileReplaceReadwriteFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_replace_readwrite_finish file' res'
        checkUnexpectedReturnNULL "fileReplaceReadwriteFinish" result
        result' <- (wrapObject Gio.FileIOStream.FileIOStream) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileReplaceReadwriteFinishMethodInfo
instance (signature ~ (b -> m Gio.FileIOStream.FileIOStream), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileReplaceReadwriteFinishMethodInfo a signature where
    overloadedMethod _ = fileReplaceReadwriteFinish

-- method File::resolve_relative_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "relative_path", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a given relative path string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_file_resolve_relative_path" g_file_resolve_relative_path :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- relative_path : TBasicType TFileName
    IO (Ptr File)

{- |
Resolves a relative path for /@file@/ to an absolute path.

This call does no blocking I\/O.
-}
fileResolveRelativePath ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Char]
    {- ^ /@relativePath@/: a given relative path string -}
    -> m File
    {- ^ __Returns:__ 'GI.Gio.Interfaces.File.File' to the resolved path.
    'Nothing' if /@relativePath@/ is 'Nothing' or if /@file@/ is invalid.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
fileResolveRelativePath file relativePath = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    relativePath' <- stringToCString relativePath
    result <- g_file_resolve_relative_path file' relativePath'
    checkUnexpectedReturnNULL "fileResolveRelativePath" result
    result' <- (wrapObject File) result
    touchManagedPtr file
    freeMem relativePath'
    return result'

data FileResolveRelativePathMethodInfo
instance (signature ~ ([Char] -> m File), MonadIO m, IsFile a) => O.MethodInfo FileResolveRelativePathMethodInfo a signature where
    overloadedMethod _ = fileResolveRelativePath

-- method File::set_attribute
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the attribute's name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "Gio", name = "FileAttributeType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The type of the attribute", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value_p", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to the value (or the pointer\n    itself if the type is a pointer type)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a set of #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_attribute" g_file_set_attribute :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attribute : TBasicType TUTF8
    CUInt ->                                -- type : TInterface (Name {namespace = "Gio", name = "FileAttributeType"})
    Ptr () ->                               -- value_p : TBasicType TPtr
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets an attribute in the file with attribute name /@attribute@/ to /@value@/.

Some attributes can be unset by setting /@attribute@/ to
'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileSetAttribute ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attribute@/: a string containing the attribute\'s name -}
    -> Gio.Enums.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) -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a set of 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetAttribute file attribute type_ valueP flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attribute' <- textToCString attribute
    let type_' = (fromIntegral . fromEnum) type_
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_set_attribute file' attribute' type_' valueP flags' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem attribute'
        return ()
     ) (do
        freeMem attribute'
     )

data FileSetAttributeMethodInfo
instance (signature ~ (T.Text -> Gio.Enums.FileAttributeType -> Ptr () -> [Gio.Flags.FileQueryInfoFlags] -> Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileSetAttributeMethodInfo a signature where
    overloadedMethod _ = fileSetAttribute

-- method File::set_attribute_byte_string
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the attribute's name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the attribute's new value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_attribute_byte_string" g_file_set_attribute_byte_string :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attribute : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets /@attribute@/ of type 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileSetAttributeByteString ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attribute@/: a string containing the attribute\'s name -}
    -> T.Text
    {- ^ /@value@/: a string containing the attribute\'s new value -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetAttributeByteString file attribute value flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attribute' <- textToCString attribute
    value' <- textToCString value
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_set_attribute_byte_string file' attribute' value' flags' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem attribute'
        freeMem value'
        return ()
     ) (do
        freeMem attribute'
        freeMem value'
     )

data FileSetAttributeByteStringMethodInfo
instance (signature ~ (T.Text -> T.Text -> [Gio.Flags.FileQueryInfoFlags] -> Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileSetAttributeByteStringMethodInfo a signature where
    overloadedMethod _ = fileSetAttributeByteString

-- method File::set_attribute_int32
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the attribute's name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gint32 containing the attribute's new value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_attribute_int32" g_file_set_attribute_int32 :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attribute : TBasicType TUTF8
    Int32 ->                                -- value : TBasicType TInt32
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets /@attribute@/ of type 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileSetAttributeInt32 ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attribute@/: a string containing the attribute\'s name -}
    -> Int32
    {- ^ /@value@/: a @/gint32/@ containing the attribute\'s new value -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetAttributeInt32 file attribute value flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attribute' <- textToCString attribute
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_set_attribute_int32 file' attribute' value flags' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem attribute'
        return ()
     ) (do
        freeMem attribute'
     )

data FileSetAttributeInt32MethodInfo
instance (signature ~ (T.Text -> Int32 -> [Gio.Flags.FileQueryInfoFlags] -> Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileSetAttributeInt32MethodInfo a signature where
    overloadedMethod _ = fileSetAttributeInt32

-- method File::set_attribute_int64
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the attribute's name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #guint64 containing the attribute's new value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_attribute_int64" g_file_set_attribute_int64 :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attribute : TBasicType TUTF8
    Int64 ->                                -- value : TBasicType TInt64
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets /@attribute@/ of type 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileSetAttributeInt64 ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attribute@/: a string containing the attribute\'s name -}
    -> Int64
    {- ^ /@value@/: a @/guint64/@ containing the attribute\'s new value -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetAttributeInt64 file attribute value flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attribute' <- textToCString attribute
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_set_attribute_int64 file' attribute' value flags' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem attribute'
        return ()
     ) (do
        freeMem attribute'
     )

data FileSetAttributeInt64MethodInfo
instance (signature ~ (T.Text -> Int64 -> [Gio.Flags.FileQueryInfoFlags] -> Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileSetAttributeInt64MethodInfo a signature where
    overloadedMethod _ = fileSetAttributeInt64

-- method File::set_attribute_string
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the attribute's name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the attribute's value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_attribute_string" g_file_set_attribute_string :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attribute : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets /@attribute@/ of type 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileSetAttributeString ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attribute@/: a string containing the attribute\'s name -}
    -> T.Text
    {- ^ /@value@/: a string containing the attribute\'s value -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetAttributeString file attribute value flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attribute' <- textToCString attribute
    value' <- textToCString value
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_set_attribute_string file' attribute' value' flags' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem attribute'
        freeMem value'
        return ()
     ) (do
        freeMem attribute'
        freeMem value'
     )

data FileSetAttributeStringMethodInfo
instance (signature ~ (T.Text -> T.Text -> [Gio.Flags.FileQueryInfoFlags] -> Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileSetAttributeStringMethodInfo a signature where
    overloadedMethod _ = fileSetAttributeString

-- method File::set_attribute_uint32
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the attribute's name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #guint32 containing the attribute's new value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_attribute_uint32" g_file_set_attribute_uint32 :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attribute : TBasicType TUTF8
    Word32 ->                               -- value : TBasicType TUInt32
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets /@attribute@/ of type 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileSetAttributeUint32 ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attribute@/: a string containing the attribute\'s name -}
    -> Word32
    {- ^ /@value@/: a @/guint32/@ containing the attribute\'s new value -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetAttributeUint32 file attribute value flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attribute' <- textToCString attribute
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_set_attribute_uint32 file' attribute' value flags' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem attribute'
        return ()
     ) (do
        freeMem attribute'
     )

data FileSetAttributeUint32MethodInfo
instance (signature ~ (T.Text -> Word32 -> [Gio.Flags.FileQueryInfoFlags] -> Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileSetAttributeUint32MethodInfo a signature where
    overloadedMethod _ = fileSetAttributeUint32

-- method File::set_attribute_uint64
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attribute", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the attribute's name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #guint64 containing the attribute's new value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_attribute_uint64" g_file_set_attribute_uint64 :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- attribute : TBasicType TUTF8
    Word64 ->                               -- value : TBasicType TUInt64
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets /@attribute@/ of type 'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileSetAttributeUint64 ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@attribute@/: a string containing the attribute\'s name -}
    -> Word64
    {- ^ /@value@/: a @/guint64/@ containing the attribute\'s new value -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetAttributeUint64 file attribute value flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    attribute' <- textToCString attribute
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_set_attribute_uint64 file' attribute' value flags' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem attribute'
        return ()
     ) (do
        freeMem attribute'
     )

data FileSetAttributeUint64MethodInfo
instance (signature ~ (T.Text -> Word64 -> [Gio.Flags.FileQueryInfoFlags] -> Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileSetAttributeUint64MethodInfo a signature where
    overloadedMethod _ = fileSetAttributeUint64

-- method File::set_attributes_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 6, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #gpointer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_set_attributes_async" g_file_set_attributes_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.FileInfo.FileInfo ->            -- info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously sets the attributes of /@file@/ with /@info@/.

For more details, see 'GI.Gio.Interfaces.File.fileSetAttributesFromInfo',
which is the synchronous version of this call.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileSetAttributesFinish' to get
the result of the operation.
-}
fileSetAttributesAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.FileInfo.IsFileInfo b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@info@/: a 'GI.Gio.Objects.FileInfo.FileInfo' -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: a 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' -}
    -> m ()
fileSetAttributesAsync file info flags ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    info' <- unsafeManagedPtrCastPtr info
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_set_attributes_async file' info' flags' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    touchManagedPtr info
    whenJust cancellable touchManagedPtr
    return ()

data FileSetAttributesAsyncMethodInfo
instance (signature ~ (b -> [Gio.Flags.FileQueryInfoFlags] -> Int32 -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.FileInfo.IsFileInfo b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileSetAttributesAsyncMethodInfo a signature where
    overloadedMethod _ = fileSetAttributesAsync

-- method File::set_attributes_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_attributes_finish" g_file_set_attributes_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr Gio.FileInfo.FileInfo) ->      -- info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes setting an attribute started in 'GI.Gio.Interfaces.File.fileSetAttributesAsync'.
-}
fileSetAttributesFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m (Gio.FileInfo.FileInfo)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetAttributesFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    info <- allocMem :: IO (Ptr (Ptr Gio.FileInfo.FileInfo))
    onException (do
        _ <- propagateGError $ g_file_set_attributes_finish file' result_' info
        info' <- peek info
        info'' <- (wrapObject Gio.FileInfo.FileInfo) info'
        touchManagedPtr file
        touchManagedPtr result_
        freeMem info
        return info''
     ) (do
        freeMem info
     )

data FileSetAttributesFinishMethodInfo
instance (signature ~ (b -> m (Gio.FileInfo.FileInfo)), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileSetAttributesFinishMethodInfo a signature where
    overloadedMethod _ = fileSetAttributesFinish

-- method File::set_attributes_from_info
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GFileQueryInfoFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_attributes_from_info" g_file_set_attributes_from_info :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.FileInfo.FileInfo ->            -- info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "FileQueryInfoFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Tries to set all attributes in the 'GI.Gio.Objects.FileInfo.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
'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileSetAttributesFromInfo ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.FileInfo.IsFileInfo b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@info@/: a 'GI.Gio.Objects.FileInfo.FileInfo' -}
    -> [Gio.Flags.FileQueryInfoFlags]
    {- ^ /@flags@/: 'GI.Gio.Flags.FileQueryInfoFlags' -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetAttributesFromInfo file info flags cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    info' <- unsafeManagedPtrCastPtr info
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_set_attributes_from_info file' info' flags' maybeCancellable
        touchManagedPtr file
        touchManagedPtr info
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data FileSetAttributesFromInfoMethodInfo
instance (signature ~ (b -> [Gio.Flags.FileQueryInfoFlags] -> Maybe (c) -> m ()), MonadIO m, IsFile a, Gio.FileInfo.IsFileInfo b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileSetAttributesFromInfoMethodInfo a signature where
    overloadedMethod _ = fileSetAttributesFromInfo

-- method File::set_display_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "display_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_display_name" g_file_set_display_name :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- display_name : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr File)

{- |
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 ('GI.Gio.Constants.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 'GI.Gio.Interfaces.File.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileSetDisplayName ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@displayName@/: a string -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m File
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.File.File' specifying what /@file@/ was renamed to,
    or 'Nothing' if there was an error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetDisplayName file displayName cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    displayName' <- textToCString displayName
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_set_display_name file' displayName' maybeCancellable
        checkUnexpectedReturnNULL "fileSetDisplayName" result
        result' <- (wrapObject File) result
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        freeMem displayName'
        return result'
     ) (do
        freeMem displayName'
     )

data FileSetDisplayNameMethodInfo
instance (signature ~ (T.Text -> Maybe (b) -> m File), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileSetDisplayNameMethodInfo a signature where
    overloadedMethod _ = fileSetDisplayName

-- method File::set_display_name_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "display_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_set_display_name_async" g_file_set_display_name_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CString ->                              -- display_name : TBasicType TUTF8
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously sets the display name for a given 'GI.Gio.Interfaces.File.File'.

For more details, see 'GI.Gio.Interfaces.File.fileSetDisplayName' which is
the synchronous version of this call.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileSetDisplayNameFinish' to get
the result of the operation.
-}
fileSetDisplayNameAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> T.Text
    {- ^ /@displayName@/: a string -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileSetDisplayNameAsync file displayName ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    displayName' <- textToCString displayName
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_set_display_name_async file' displayName' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    freeMem displayName'
    return ()

data FileSetDisplayNameAsyncMethodInfo
instance (signature ~ (T.Text -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileSetDisplayNameAsyncMethodInfo a signature where
    overloadedMethod _ = fileSetDisplayNameAsync

-- method File::set_display_name_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_set_display_name_finish" g_file_set_display_name_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr File)

{- |
Finishes setting a display name started with
'GI.Gio.Interfaces.File.fileSetDisplayNameAsync'.
-}
fileSetDisplayNameFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@res@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m File
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.File.File' or 'Nothing' on error.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileSetDisplayNameFinish file res = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_file_set_display_name_finish file' res'
        checkUnexpectedReturnNULL "fileSetDisplayNameFinish" result
        result' <- (wrapObject File) result
        touchManagedPtr file
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data FileSetDisplayNameFinishMethodInfo
instance (signature ~ (b -> m File), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileSetDisplayNameFinishMethodInfo a signature where
    overloadedMethod _ = fileSetDisplayNameFinish

-- method File::start_mountable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "DriveStartFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the operation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation, or %NULL to avoid user interaction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the request is satisfied, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_start_mountable" g_file_start_mountable :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DriveStartFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- start_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileMountMountableFinish' to get
the result of the operation.

@since 2.22
-}
fileStartMountable ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.DriveStartFlags]
    {- ^ /@flags@/: flags affecting the operation -}
    -> Maybe (b)
    {- ^ /@startOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation', or 'Nothing' to avoid user interaction -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the request is satisfied, or 'Nothing' -}
    -> m ()
fileStartMountable file flags startOperation cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeStartOperation <- case startOperation of
        Nothing -> return nullPtr
        Just jStartOperation -> do
            jStartOperation' <- unsafeManagedPtrCastPtr jStartOperation
            return jStartOperation'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_start_mountable file' flags' maybeStartOperation maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust startOperation touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

data FileStartMountableMethodInfo
instance (signature ~ ([Gio.Flags.DriveStartFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileStartMountableMethodInfo a signature where
    overloadedMethod _ = fileStartMountable

-- method File::start_mountable_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_start_mountable_finish" g_file_start_mountable_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes a start operation. See 'GI.Gio.Interfaces.File.fileStartMountable' for details.

Finish an asynchronous start operation that was started
with 'GI.Gio.Interfaces.File.fileStartMountable'.

@since 2.22
-}
fileStartMountableFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileStartMountableFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_start_mountable_finish file' result_'
        touchManagedPtr file
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FileStartMountableFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileStartMountableFinishMethodInfo a signature where
    overloadedMethod _ = fileStartMountableFinish

-- method File::stop_mountable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the operation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mount_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation,\n    or %NULL to avoid user interaction.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_stop_mountable" g_file_stop_mountable :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- mount_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileStopMountableFinish' to get
the result of the operation.

@since 2.22
-}
fileStopMountable ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.MountUnmountFlags]
    {- ^ /@flags@/: flags affecting the operation -}
    -> Maybe (b)
    {- ^ /@mountOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation',
    or 'Nothing' to avoid user interaction. -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied, or 'Nothing' -}
    -> m ()
fileStopMountable file flags mountOperation cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeMountOperation <- case mountOperation of
        Nothing -> return nullPtr
        Just jMountOperation -> do
            jMountOperation' <- unsafeManagedPtrCastPtr jMountOperation
            return jMountOperation'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_stop_mountable file' flags' maybeMountOperation maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust mountOperation touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

data FileStopMountableMethodInfo
instance (signature ~ ([Gio.Flags.MountUnmountFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileStopMountableMethodInfo a signature where
    overloadedMethod _ = fileStopMountable

-- method File::stop_mountable_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_stop_mountable_finish" g_file_stop_mountable_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes an stop operation, see 'GI.Gio.Interfaces.File.fileStopMountable' for details.

Finish an asynchronous stop operation that was started
with 'GI.Gio.Interfaces.File.fileStopMountable'.

@since 2.22
-}
fileStopMountableFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileStopMountableFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_stop_mountable_finish file' result_'
        touchManagedPtr file
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FileStopMountableFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileStopMountableFinishMethodInfo a signature where
    overloadedMethod _ = fileStopMountableFinish

-- method File::supports_thread_contexts
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_file_supports_thread_contexts" g_file_supports_thread_contexts :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO CInt

{- |
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
-}
fileSupportsThreadContexts ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a) =>
    a
    {- ^ /@file@/: a 'GI.Gio.Interfaces.File.File' -}
    -> m Bool
    {- ^ __Returns:__ Whether or not /@file@/ supports thread-default contexts. -}
fileSupportsThreadContexts file = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result <- g_file_supports_thread_contexts file'
    let result' = (/= 0) result
    touchManagedPtr file
    return result'

data FileSupportsThreadContextsMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsFile a) => O.MethodInfo FileSupportsThreadContextsMethodInfo a signature where
    overloadedMethod _ = fileSupportsThreadContexts

-- method File::trash
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GFile to send to trash", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_trash" g_file_trash :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
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
'GI.Gio.Enums.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.
-}
fileTrash ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: 'GI.Gio.Interfaces.File.File' to send to trash -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileTrash file cancellable = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_trash file' maybeCancellable
        touchManagedPtr file
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data FileTrashMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileTrashMethodInfo a signature where
    overloadedMethod _ = fileTrash

-- method File::trash_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_trash_async" g_file_trash_async :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously sends /@file@/ to the Trash location, if possible.

@since 2.38
-}
fileTrashAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied -}
    -> m ()
fileTrashAsync file ioPriority cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_trash_async file' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileTrashAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileTrashAsyncMethodInfo a signature where
    overloadedMethod _ = fileTrashAsync

-- method File::trash_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_trash_finish" g_file_trash_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes an asynchronous file trashing operation, started with
'GI.Gio.Interfaces.File.fileTrashAsync'.

@since 2.38
-}
fileTrashFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileTrashFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_trash_finish file' result_'
        touchManagedPtr file
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FileTrashFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileTrashFinishMethodInfo a signature where
    overloadedMethod _ = fileTrashFinish

-- method File::unmount_mountable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the operation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_unmount_mountable" g_file_unmount_mountable :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{-# DEPRECATED fileUnmountMountable ["(Since version 2.22)","Use 'GI.Gio.Interfaces.File.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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileUnmountMountableFinish' to get
the result of the operation.
-}
fileUnmountMountable ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.MountUnmountFlags]
    {- ^ /@flags@/: flags affecting the operation -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied, or 'Nothing' -}
    -> m ()
fileUnmountMountable file flags cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_unmount_mountable file' flags' maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust cancellable touchManagedPtr
    return ()

data FileUnmountMountableMethodInfo
instance (signature ~ ([Gio.Flags.MountUnmountFlags] -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileUnmountMountableMethodInfo a signature where
    overloadedMethod _ = fileUnmountMountable

-- method File::unmount_mountable_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_unmount_mountable_finish" g_file_unmount_mountable_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED fileUnmountMountableFinish ["(Since version 2.22)","Use 'GI.Gio.Interfaces.File.fileUnmountMountableWithOperationFinish'","    instead."] #-}
{- |
Finishes an unmount operation, see 'GI.Gio.Interfaces.File.fileUnmountMountable' for details.

Finish an asynchronous unmount operation that was started
with 'GI.Gio.Interfaces.File.fileUnmountMountable'.
-}
fileUnmountMountableFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileUnmountMountableFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_unmount_mountable_finish file' result_'
        touchManagedPtr file
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FileUnmountMountableFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileUnmountMountableFinishMethodInfo a signature where
    overloadedMethod _ = fileUnmountMountableFinish

-- method File::unmount_mountable_with_operation
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the operation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mount_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation,\n    or %NULL to avoid user interaction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object,\n    %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call\n    when the request is satisfied, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_file_unmount_mountable_with_operation" g_file_unmount_mountable_with_operation :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- mount_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
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 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned.

When the operation is finished, /@callback@/ will be called.
You can then call 'GI.Gio.Interfaces.File.fileUnmountMountableFinish' to get
the result of the operation.

@since 2.22
-}
fileUnmountMountableWithOperation ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> [Gio.Flags.MountUnmountFlags]
    {- ^ /@flags@/: flags affecting the operation -}
    -> Maybe (b)
    {- ^ /@mountOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation',
    or 'Nothing' to avoid user interaction -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object,
    'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call
    when the request is satisfied, or 'Nothing' -}
    -> m ()
fileUnmountMountableWithOperation file flags mountOperation cancellable callback = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    let flags' = gflagsToWord flags
    maybeMountOperation <- case mountOperation of
        Nothing -> return nullPtr
        Just jMountOperation -> do
            jMountOperation' <- unsafeManagedPtrCastPtr jMountOperation
            return jMountOperation'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_file_unmount_mountable_with_operation file' flags' maybeMountOperation maybeCancellable maybeCallback userData
    touchManagedPtr file
    whenJust mountOperation touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

data FileUnmountMountableWithOperationMethodInfo
instance (signature ~ ([Gio.Flags.MountUnmountFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFile a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo FileUnmountMountableWithOperationMethodInfo a signature where
    overloadedMethod _ = fileUnmountMountableWithOperation

-- method File::unmount_mountable_with_operation_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input #GFile", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_unmount_mountable_with_operation_finish" g_file_unmount_mountable_with_operation_finish :: 
    Ptr File ->                             -- file : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes an unmount operation,
see 'GI.Gio.Interfaces.File.fileUnmountMountableWithOperation' for details.

Finish an asynchronous unmount operation that was started
with 'GI.Gio.Interfaces.File.fileUnmountMountableWithOperation'.

@since 2.22
-}
fileUnmountMountableWithOperationFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@file@/: input 'GI.Gio.Interfaces.File.File' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileUnmountMountableWithOperationFinish file result_ = liftIO $ do
    file' <- unsafeManagedPtrCastPtr file
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_unmount_mountable_with_operation_finish file' result_'
        touchManagedPtr file
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data FileUnmountMountableWithOperationFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFile a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileUnmountMountableWithOperationFinishMethodInfo a signature where
    overloadedMethod _ = fileUnmountMountableWithOperationFinish

-- method File::new_for_commandline_arg
-- method type : MemberFunction
-- Args : [Arg {argCName = "arg", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a command line string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_file_new_for_commandline_arg" g_file_new_for_commandline_arg :: 
    CString ->                              -- arg : TBasicType TUTF8
    IO (Ptr File)

{- |
Creates a 'GI.Gio.Interfaces.File.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.  'GI.Gio.Objects.Application.Application' also uses UTF-8 but
'GI.Gio.Objects.ApplicationCommandLine.applicationCommandLineCreateFileForArg' may be more useful
for you there.  It is also always possible to use this function with
'GI.GLib.Structs.OptionContext.OptionContext' arguments of type 'GI.GLib.Enums.OptionArgFilename'.
-}
fileNewForCommandlineArg ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@arg@/: a command line string -}
    -> m File
    {- ^ __Returns:__ a new 'GI.Gio.Interfaces.File.File'.
   Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
fileNewForCommandlineArg arg = liftIO $ do
    arg' <- textToCString arg
    result <- g_file_new_for_commandline_arg arg'
    checkUnexpectedReturnNULL "fileNewForCommandlineArg" result
    result' <- (wrapObject File) result
    freeMem arg'
    return result'

-- method File::new_for_commandline_arg_and_cwd
-- method type : MemberFunction
-- Args : [Arg {argCName = "arg", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a command line string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cwd", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the current working directory of the commandline", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_file_new_for_commandline_arg_and_cwd" g_file_new_for_commandline_arg_and_cwd :: 
    CString ->                              -- arg : TBasicType TUTF8
    CString ->                              -- cwd : TBasicType TFileName
    IO (Ptr File)

{- |
Creates a 'GI.Gio.Interfaces.File.File' with the given argument from the command line.

This function is similar to 'GI.Gio.Functions.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 'GI.Gio.Objects.ApplicationCommandLine.applicationCommandLineCreateFileForArg'.

@since 2.36
-}
fileNewForCommandlineArgAndCwd ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@arg@/: a command line string -}
    -> [Char]
    {- ^ /@cwd@/: the current working directory of the commandline -}
    -> m File
    {- ^ __Returns:__ a new 'GI.Gio.Interfaces.File.File' -}
fileNewForCommandlineArgAndCwd arg cwd = liftIO $ do
    arg' <- textToCString arg
    cwd' <- stringToCString cwd
    result <- g_file_new_for_commandline_arg_and_cwd arg' cwd'
    checkUnexpectedReturnNULL "fileNewForCommandlineArgAndCwd" result
    result' <- (wrapObject File) result
    freeMem arg'
    freeMem cwd'
    return result'

-- method File::new_for_path
-- method type : MemberFunction
-- Args : [Arg {argCName = "path", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing a relative or absolute path.\n    The string must be encoded in the glib filename encoding.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_file_new_for_path" g_file_new_for_path :: 
    CString ->                              -- path : TBasicType TFileName
    IO (Ptr File)

{- |
Constructs a 'GI.Gio.Interfaces.File.File' for a given path. This operation never
fails, but the returned object might not support any I\/O
operation if /@path@/ is malformed.
-}
fileNewForPath ::
    (B.CallStack.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 'GI.Gio.Interfaces.File.File' for the given /@path@/.
  Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
fileNewForPath path = liftIO $ do
    path' <- stringToCString path
    result <- g_file_new_for_path path'
    checkUnexpectedReturnNULL "fileNewForPath" result
    result' <- (wrapObject File) result
    freeMem path'
    return result'

-- method File::new_for_uri
-- method type : MemberFunction
-- Args : [Arg {argCName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 string containing a URI", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_file_new_for_uri" g_file_new_for_uri :: 
    CString ->                              -- uri : TBasicType TUTF8
    IO (Ptr File)

{- |
Constructs a 'GI.Gio.Interfaces.File.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.
-}
fileNewForUri ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@uri@/: a UTF-8 string containing a URI -}
    -> m File
    {- ^ __Returns:__ a new 'GI.Gio.Interfaces.File.File' for the given /@uri@/.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
fileNewForUri uri = liftIO $ do
    uri' <- textToCString uri
    result <- g_file_new_for_uri uri'
    checkUnexpectedReturnNULL "fileNewForUri" result
    result' <- (wrapObject File) result
    freeMem uri'
    return result'

-- method File::new_tmp
-- method type : MemberFunction
-- Args : [Arg {argCName = "tmpl", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Template for the file\n  name, as in g_file_open_tmp(), or %NULL for a default template", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iostream", argType = TInterface (Name {namespace = "Gio", name = "FileIOStream"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "on return, a #GFileIOStream for the created file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_new_tmp" g_file_new_tmp :: 
    CString ->                              -- tmpl : TBasicType TFileName
    Ptr (Ptr Gio.FileIOStream.FileIOStream) -> -- iostream : TInterface (Name {namespace = "Gio", name = "FileIOStream"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr File)

{- |
Opens a file in the preferred directory for temporary files (as
returned by 'GI.GLib.Functions.getTmpDir') and returns a 'GI.Gio.Interfaces.File.File' and
'GI.Gio.Objects.FileIOStream.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 'GI.Gio.Interfaces.File.File' constructors, this will return 'Nothing' if
a temporary file could not be created.

@since 2.32
-}
fileNewTmp ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe ([Char])
    {- ^ /@tmpl@/: Template for the file
  name, as in 'GI.GLib.Functions.fileOpenTmp', or 'Nothing' for a default template -}
    -> m (File,Gio.FileIOStream.FileIOStream)
    {- ^ __Returns:__ a new 'GI.Gio.Interfaces.File.File'.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileNewTmp tmpl = liftIO $ do
    maybeTmpl <- case tmpl of
        Nothing -> return nullPtr
        Just jTmpl -> do
            jTmpl' <- stringToCString jTmpl
            return jTmpl'
    iostream <- allocMem :: IO (Ptr (Ptr Gio.FileIOStream.FileIOStream))
    onException (do
        result <- propagateGError $ g_file_new_tmp maybeTmpl iostream
        checkUnexpectedReturnNULL "fileNewTmp" result
        result' <- (wrapObject File) result
        iostream' <- peek iostream
        iostream'' <- (wrapObject Gio.FileIOStream.FileIOStream) iostream'
        freeMem maybeTmpl
        freeMem iostream
        return (result', iostream'')
     ) (do
        freeMem maybeTmpl
        freeMem iostream
     )

-- method File::parse_name
-- method type : MemberFunction
-- Args : [Arg {argCName = "parse_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file name or path to be parsed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_file_parse_name" g_file_parse_name :: 
    CString ->                              -- parse_name : TBasicType TUTF8
    IO (Ptr File)

{- |
Constructs a 'GI.Gio.Interfaces.File.File' with the given /@parseName@/ (i.e. something
given by 'GI.Gio.Interfaces.File.fileGetParseName'). This operation never fails,
but the returned object might not support any I\/O operation if
the /@parseName@/ cannot be parsed.
-}
fileParseName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@parseName@/: a file name or path to be parsed -}
    -> m File
    {- ^ __Returns:__ a new 'GI.Gio.Interfaces.File.File'. -}
fileParseName parseName = liftIO $ do
    parseName' <- textToCString parseName
    result <- g_file_parse_name parseName'
    checkUnexpectedReturnNULL "fileParseName" result
    result' <- (wrapObject File) result
    freeMem parseName'
    return result'