{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'GI.Gio.Objects.FileEnumerator.FileEnumerator' allows you to operate on a set of @/GFiles/@,
-- returning a t'GI.Gio.Objects.FileInfo.FileInfo' structure for each file enumerated (e.g.
-- 'GI.Gio.Interfaces.File.fileEnumerateChildren' will return a t'GI.Gio.Objects.FileEnumerator.FileEnumerator' for each
-- of the children within a directory).
-- 
-- To get the next file\'s information from a t'GI.Gio.Objects.FileEnumerator.FileEnumerator', use
-- 'GI.Gio.Objects.FileEnumerator.fileEnumeratorNextFile' or its asynchronous version,
-- 'GI.Gio.Objects.FileEnumerator.fileEnumeratorNextFilesAsync'. Note that the asynchronous
-- version will return a list of @/GFileInfos/@, whereas the
-- synchronous will only return the next file in the enumerator.
-- 
-- The ordering of returned files is unspecified for non-Unix
-- platforms; for more information, see 'GI.GLib.Structs.Dir.dirReadName'.  On Unix,
-- when operating on local files, returned files will be sorted by
-- inode number.  Effectively you can assume that the ordering of
-- returned files will be stable between successive calls (and
-- applications) assuming the directory is unchanged.
-- 
-- If your application needs a specific ordering, such as by name or
-- modification time, you will have to implement that in your
-- application code.
-- 
-- To close a t'GI.Gio.Objects.FileEnumerator.FileEnumerator', use 'GI.Gio.Objects.FileEnumerator.fileEnumeratorClose', or
-- its asynchronous version, 'GI.Gio.Objects.FileEnumerator.fileEnumeratorCloseAsync'. Once
-- a t'GI.Gio.Objects.FileEnumerator.FileEnumerator' is closed, no further actions may be performed
-- on it, and it should be freed with 'GI.GObject.Objects.Object.objectUnref'.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Gio.Objects.FileEnumerator
    ( 

-- * Exported types
    FileEnumerator(..)                      ,
    IsFileEnumerator                        ,
    toFileEnumerator                        ,
    noFileEnumerator                        ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveFileEnumeratorMethod             ,
#endif


-- ** close #method:close#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorCloseMethodInfo           ,
#endif
    fileEnumeratorClose                     ,


-- ** closeAsync #method:closeAsync#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorCloseAsyncMethodInfo      ,
#endif
    fileEnumeratorCloseAsync                ,


-- ** closeFinish #method:closeFinish#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorCloseFinishMethodInfo     ,
#endif
    fileEnumeratorCloseFinish               ,


-- ** getChild #method:getChild#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorGetChildMethodInfo        ,
#endif
    fileEnumeratorGetChild                  ,


-- ** getContainer #method:getContainer#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorGetContainerMethodInfo    ,
#endif
    fileEnumeratorGetContainer              ,


-- ** hasPending #method:hasPending#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorHasPendingMethodInfo      ,
#endif
    fileEnumeratorHasPending                ,


-- ** isClosed #method:isClosed#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorIsClosedMethodInfo        ,
#endif
    fileEnumeratorIsClosed                  ,


-- ** iterate #method:iterate#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorIterateMethodInfo         ,
#endif
    fileEnumeratorIterate                   ,


-- ** nextFile #method:nextFile#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorNextFileMethodInfo        ,
#endif
    fileEnumeratorNextFile                  ,


-- ** nextFilesAsync #method:nextFilesAsync#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorNextFilesAsyncMethodInfo  ,
#endif
    fileEnumeratorNextFilesAsync            ,


-- ** nextFilesFinish #method:nextFilesFinish#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorNextFilesFinishMethodInfo ,
#endif
    fileEnumeratorNextFilesFinish           ,


-- ** setPending #method:setPending#

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorSetPendingMethodInfo      ,
#endif
    fileEnumeratorSetPending                ,




 -- * Properties
-- ** container #attr:container#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    FileEnumeratorContainerPropertyInfo     ,
#endif
    constructFileEnumeratorContainer        ,
#if defined(ENABLE_OVERLOADING)
    fileEnumeratorContainer                 ,
#endif




    ) 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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
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 GHC.OverloadedLabels as OL

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.File as Gio.File
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.FileInfo as Gio.FileInfo

-- | Memory-managed wrapper type.
newtype FileEnumerator = FileEnumerator (ManagedPtr FileEnumerator)
    deriving (FileEnumerator -> FileEnumerator -> Bool
(FileEnumerator -> FileEnumerator -> Bool)
-> (FileEnumerator -> FileEnumerator -> Bool) -> Eq FileEnumerator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileEnumerator -> FileEnumerator -> Bool
$c/= :: FileEnumerator -> FileEnumerator -> Bool
== :: FileEnumerator -> FileEnumerator -> Bool
$c== :: FileEnumerator -> FileEnumerator -> Bool
Eq)
foreign import ccall "g_file_enumerator_get_type"
    c_g_file_enumerator_get_type :: IO GType

instance GObject FileEnumerator where
    gobjectType :: IO GType
gobjectType = IO GType
c_g_file_enumerator_get_type
    

-- | Convert 'FileEnumerator' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue FileEnumerator where
    toGValue :: FileEnumerator -> IO GValue
toGValue o :: FileEnumerator
o = do
        GType
gtype <- IO GType
c_g_file_enumerator_get_type
        FileEnumerator -> (Ptr FileEnumerator -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr FileEnumerator
o (GType
-> (GValue -> Ptr FileEnumerator -> IO ())
-> Ptr FileEnumerator
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr FileEnumerator -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO FileEnumerator
fromGValue gv :: GValue
gv = do
        Ptr FileEnumerator
ptr <- GValue -> IO (Ptr FileEnumerator)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr FileEnumerator)
        (ManagedPtr FileEnumerator -> FileEnumerator)
-> Ptr FileEnumerator -> IO FileEnumerator
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr FileEnumerator -> FileEnumerator
FileEnumerator Ptr FileEnumerator
ptr
        
    

-- | Type class for types which can be safely cast to `FileEnumerator`, for instance with `toFileEnumerator`.
class (GObject o, O.IsDescendantOf FileEnumerator o) => IsFileEnumerator o
instance (GObject o, O.IsDescendantOf FileEnumerator o) => IsFileEnumerator o

instance O.HasParentTypes FileEnumerator
type instance O.ParentTypes FileEnumerator = '[GObject.Object.Object]

-- | Cast to `FileEnumerator`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toFileEnumerator :: (MonadIO m, IsFileEnumerator o) => o -> m FileEnumerator
toFileEnumerator :: o -> m FileEnumerator
toFileEnumerator = IO FileEnumerator -> m FileEnumerator
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO FileEnumerator -> m FileEnumerator)
-> (o -> IO FileEnumerator) -> o -> m FileEnumerator
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr FileEnumerator -> FileEnumerator)
-> o -> IO FileEnumerator
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr FileEnumerator -> FileEnumerator
FileEnumerator

-- | A convenience alias for `Nothing` :: `Maybe` `FileEnumerator`.
noFileEnumerator :: Maybe FileEnumerator
noFileEnumerator :: Maybe FileEnumerator
noFileEnumerator = Maybe FileEnumerator
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
type family ResolveFileEnumeratorMethod (t :: Symbol) (o :: *) :: * where
    ResolveFileEnumeratorMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveFileEnumeratorMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveFileEnumeratorMethod "close" o = FileEnumeratorCloseMethodInfo
    ResolveFileEnumeratorMethod "closeAsync" o = FileEnumeratorCloseAsyncMethodInfo
    ResolveFileEnumeratorMethod "closeFinish" o = FileEnumeratorCloseFinishMethodInfo
    ResolveFileEnumeratorMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveFileEnumeratorMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveFileEnumeratorMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveFileEnumeratorMethod "hasPending" o = FileEnumeratorHasPendingMethodInfo
    ResolveFileEnumeratorMethod "isClosed" o = FileEnumeratorIsClosedMethodInfo
    ResolveFileEnumeratorMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveFileEnumeratorMethod "iterate" o = FileEnumeratorIterateMethodInfo
    ResolveFileEnumeratorMethod "nextFile" o = FileEnumeratorNextFileMethodInfo
    ResolveFileEnumeratorMethod "nextFilesAsync" o = FileEnumeratorNextFilesAsyncMethodInfo
    ResolveFileEnumeratorMethod "nextFilesFinish" o = FileEnumeratorNextFilesFinishMethodInfo
    ResolveFileEnumeratorMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveFileEnumeratorMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveFileEnumeratorMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveFileEnumeratorMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveFileEnumeratorMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveFileEnumeratorMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveFileEnumeratorMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveFileEnumeratorMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveFileEnumeratorMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveFileEnumeratorMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveFileEnumeratorMethod "getChild" o = FileEnumeratorGetChildMethodInfo
    ResolveFileEnumeratorMethod "getContainer" o = FileEnumeratorGetContainerMethodInfo
    ResolveFileEnumeratorMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveFileEnumeratorMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveFileEnumeratorMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveFileEnumeratorMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveFileEnumeratorMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveFileEnumeratorMethod "setPending" o = FileEnumeratorSetPendingMethodInfo
    ResolveFileEnumeratorMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveFileEnumeratorMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveFileEnumeratorMethod t FileEnumerator, O.MethodInfo info FileEnumerator p) => OL.IsLabel t (FileEnumerator -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

-- VVV Prop "container"
   -- Type: TInterface (Name {namespace = "Gio", name = "File"})
   -- Flags: [PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

-- | Construct a `GValueConstruct` with valid value for the “@container@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructFileEnumeratorContainer :: (IsFileEnumerator o, Gio.File.IsFile a) => a -> IO (GValueConstruct o)
constructFileEnumeratorContainer :: a -> IO (GValueConstruct o)
constructFileEnumeratorContainer val :: a
val = String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject "container" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorContainerPropertyInfo
instance AttrInfo FileEnumeratorContainerPropertyInfo where
    type AttrAllowedOps FileEnumeratorContainerPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
    type AttrBaseTypeConstraint FileEnumeratorContainerPropertyInfo = IsFileEnumerator
    type AttrSetTypeConstraint FileEnumeratorContainerPropertyInfo = Gio.File.IsFile
    type AttrTransferTypeConstraint FileEnumeratorContainerPropertyInfo = Gio.File.IsFile
    type AttrTransferType FileEnumeratorContainerPropertyInfo = Gio.File.File
    type AttrGetType FileEnumeratorContainerPropertyInfo = ()
    type AttrLabel FileEnumeratorContainerPropertyInfo = "container"
    type AttrOrigin FileEnumeratorContainerPropertyInfo = FileEnumerator
    attrGet = undefined
    attrSet = undefined
    attrTransfer _ v = do
        unsafeCastTo Gio.File.File v
    attrConstruct = constructFileEnumeratorContainer
    attrClear = undefined
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList FileEnumerator
type instance O.AttributeList FileEnumerator = FileEnumeratorAttributeList
type FileEnumeratorAttributeList = ('[ '("container", FileEnumeratorContainerPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
fileEnumeratorContainer :: AttrLabelProxy "container"
fileEnumeratorContainer = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList FileEnumerator = FileEnumeratorSignalList
type FileEnumeratorSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method FileEnumerator::close
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator."
--                 , 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 (TBasicType TBoolean)
-- throws : True
-- Skip return : False

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

-- | Releases all resources used by this enumerator, making the
-- enumerator return 'GI.Gio.Enums.IOErrorEnumClosed' on all calls.
-- 
-- This will be automatically called when the last reference
-- is dropped, but you might want to call this function to make
-- sure resources are released as early as possible.
fileEnumeratorClose ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'.
    -> Maybe (b)
    -- ^ /@cancellable@/: optional t'GI.Gio.Objects.Cancellable.Cancellable' object, 'P.Nothing' to ignore.
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
fileEnumeratorClose :: a -> Maybe b -> m ()
fileEnumeratorClose enumerator :: a
enumerator cancellable :: Maybe b
cancellable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr FileEnumerator
-> Ptr Cancellable -> Ptr (Ptr GError) -> IO CInt
g_file_enumerator_close Ptr FileEnumerator
enumerator' Ptr Cancellable
maybeCancellable
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorCloseMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileEnumeratorCloseMethodInfo a signature where
    overloadedMethod = fileEnumeratorClose

#endif

-- method FileEnumerator::close_async
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator."
--                 , 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, %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 = 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_enumerator_close_async" g_file_enumerator_close_async :: 
    Ptr FileEnumerator ->                   -- enumerator : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    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 closes the file enumerator.
-- 
-- If /@cancellable@/ is not 'P.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 in
-- 'GI.Gio.Objects.FileEnumerator.fileEnumeratorCloseFinish'.
fileEnumeratorCloseAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'.
    -> Int32
    -- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request
    -> Maybe (b)
    -- ^ /@cancellable@/: optional t'GI.Gio.Objects.Cancellable.Cancellable' object, 'P.Nothing' to ignore.
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: a t'GI.Gio.Callbacks.AsyncReadyCallback' to call when the request is satisfied
    -> m ()
fileEnumeratorCloseAsync :: a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
fileEnumeratorCloseAsync enumerator :: a
enumerator ioPriority :: Int32
ioPriority cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr FileEnumerator
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_enumerator_close_async Ptr FileEnumerator
enumerator' Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorCloseAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileEnumeratorCloseAsyncMethodInfo a signature where
    overloadedMethod = fileEnumeratorCloseAsync

#endif

-- method FileEnumerator::close_finish
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator."
--                 , 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_enumerator_close_finish" g_file_enumerator_close_finish :: 
    Ptr FileEnumerator ->                   -- enumerator : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Finishes closing a file enumerator, started from 'GI.Gio.Objects.FileEnumerator.fileEnumeratorCloseAsync'.
-- 
-- If the file enumerator was already closed when 'GI.Gio.Objects.FileEnumerator.fileEnumeratorCloseAsync'
-- was called, then this function will report 'GI.Gio.Enums.IOErrorEnumClosed' in /@error@/, and
-- return 'P.False'. If the file enumerator had pending operation when the close
-- operation was started, then this function will report 'GI.Gio.Enums.IOErrorEnumPending', and
-- return 'P.False'.  If /@cancellable@/ was not 'P.Nothing', then the operation may have been
-- cancelled by triggering the cancellable object from another thread. If the operation
-- was cancelled, the error 'GI.Gio.Enums.IOErrorEnumCancelled' will be set, and 'P.False' will be
-- returned.
fileEnumeratorCloseFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'.
    -> b
    -- ^ /@result@/: a t'GI.Gio.Interfaces.AsyncResult.AsyncResult'.
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
fileEnumeratorCloseFinish :: a -> b -> m ()
fileEnumeratorCloseFinish enumerator :: a
enumerator result_ :: b
result_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr FileEnumerator
-> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_file_enumerator_close_finish Ptr FileEnumerator
enumerator' Ptr AsyncResult
result_'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorCloseFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFileEnumerator a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileEnumeratorCloseFinishMethodInfo a signature where
    overloadedMethod = fileEnumeratorCloseFinish

#endif

-- method FileEnumerator::get_child
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator" , 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 gotten from g_file_enumerator_next_file()\n  or the async equivalents."
--                 , 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_enumerator_get_child" g_file_enumerator_get_child :: 
    Ptr FileEnumerator ->                   -- enumerator : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    Ptr Gio.FileInfo.FileInfo ->            -- info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    IO (Ptr Gio.File.File)

-- | Return a new t'GI.Gio.Interfaces.File.File' which refers to the file named by /@info@/ in the source
-- directory of /@enumerator@/.  This function is primarily intended to be used
-- inside loops with 'GI.Gio.Objects.FileEnumerator.fileEnumeratorNextFile'.
-- 
-- This is a convenience method that\'s equivalent to:
-- 
-- === /C code/
-- >
-- >  gchar *name = g_file_info_get_name (info);
-- >  GFile *child = g_file_get_child (g_file_enumerator_get_container (enumr),
-- >                                   name);
-- 
-- 
-- /Since: 2.36/
fileEnumeratorGetChild ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a, Gio.FileInfo.IsFileInfo b) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'
    -> b
    -- ^ /@info@/: a t'GI.Gio.Objects.FileInfo.FileInfo' gotten from 'GI.Gio.Objects.FileEnumerator.fileEnumeratorNextFile'
    --   or the async equivalents.
    -> m Gio.File.File
    -- ^ __Returns:__ a t'GI.Gio.Interfaces.File.File' for the t'GI.Gio.Objects.FileInfo.FileInfo' passed it.
fileEnumeratorGetChild :: a -> b -> m File
fileEnumeratorGetChild enumerator :: a
enumerator info :: b
info = IO File -> m File
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO File -> m File) -> IO File -> m File
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    Ptr FileInfo
info' <- b -> IO (Ptr FileInfo)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
info
    Ptr File
result <- Ptr FileEnumerator -> Ptr FileInfo -> IO (Ptr File)
g_file_enumerator_get_child Ptr FileEnumerator
enumerator' Ptr FileInfo
info'
    Text -> Ptr File -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "fileEnumeratorGetChild" Ptr File
result
    File
result' <- ((ManagedPtr File -> File) -> Ptr File -> IO File
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr File -> File
Gio.File.File) Ptr File
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
info
    File -> IO File
forall (m :: * -> *) a. Monad m => a -> m a
return File
result'

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorGetChildMethodInfo
instance (signature ~ (b -> m Gio.File.File), MonadIO m, IsFileEnumerator a, Gio.FileInfo.IsFileInfo b) => O.MethodInfo FileEnumeratorGetChildMethodInfo a signature where
    overloadedMethod = fileEnumeratorGetChild

#endif

-- method FileEnumerator::get_container
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator" , 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_enumerator_get_container" g_file_enumerator_get_container :: 
    Ptr FileEnumerator ->                   -- enumerator : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    IO (Ptr Gio.File.File)

-- | Get the t'GI.Gio.Interfaces.File.File' container which is being enumerated.
-- 
-- /Since: 2.18/
fileEnumeratorGetContainer ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'
    -> m Gio.File.File
    -- ^ __Returns:__ the t'GI.Gio.Interfaces.File.File' which is being enumerated.
fileEnumeratorGetContainer :: a -> m File
fileEnumeratorGetContainer enumerator :: a
enumerator = IO File -> m File
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO File -> m File) -> IO File -> m File
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    Ptr File
result <- Ptr FileEnumerator -> IO (Ptr File)
g_file_enumerator_get_container Ptr FileEnumerator
enumerator'
    Text -> Ptr File -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "fileEnumeratorGetContainer" Ptr File
result
    File
result' <- ((ManagedPtr File -> File) -> Ptr File -> IO File
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr File -> File
Gio.File.File) Ptr File
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
    File -> IO File
forall (m :: * -> *) a. Monad m => a -> m a
return File
result'

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorGetContainerMethodInfo
instance (signature ~ (m Gio.File.File), MonadIO m, IsFileEnumerator a) => O.MethodInfo FileEnumeratorGetContainerMethodInfo a signature where
    overloadedMethod = fileEnumeratorGetContainer

#endif

-- method FileEnumerator::has_pending
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator."
--                 , 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_enumerator_has_pending" g_file_enumerator_has_pending :: 
    Ptr FileEnumerator ->                   -- enumerator : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    IO CInt

-- | Checks if the file enumerator has pending operations.
fileEnumeratorHasPending ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'.
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the /@enumerator@/ has pending operations.
fileEnumeratorHasPending :: a -> m Bool
fileEnumeratorHasPending enumerator :: a
enumerator = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    CInt
result <- Ptr FileEnumerator -> IO CInt
g_file_enumerator_has_pending Ptr FileEnumerator
enumerator'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorHasPendingMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsFileEnumerator a) => O.MethodInfo FileEnumeratorHasPendingMethodInfo a signature where
    overloadedMethod = fileEnumeratorHasPending

#endif

-- method FileEnumerator::is_closed
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator."
--                 , 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_enumerator_is_closed" g_file_enumerator_is_closed :: 
    Ptr FileEnumerator ->                   -- enumerator : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    IO CInt

-- | Checks if the file enumerator has been closed.
fileEnumeratorIsClosed ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'.
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the /@enumerator@/ is closed.
fileEnumeratorIsClosed :: a -> m Bool
fileEnumeratorIsClosed enumerator :: a
enumerator = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    CInt
result <- Ptr FileEnumerator -> IO CInt
g_file_enumerator_is_closed Ptr FileEnumerator
enumerator'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorIsClosedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsFileEnumerator a) => O.MethodInfo FileEnumeratorIsClosedMethodInfo a signature where
    overloadedMethod = fileEnumeratorIsClosed

#endif

-- method FileEnumerator::iterate
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "direnum"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an open #GFileEnumerator"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "out_info"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileInfo" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "Output location for the next #GFileInfo, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "out_child"
--           , argType = TInterface Name { namespace = "Gio" , name = "File" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Output location for the next #GFile, or %NULL"
--                 , 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 (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_file_enumerator_iterate" g_file_enumerator_iterate :: 
    Ptr FileEnumerator ->                   -- direnum : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    Ptr (Ptr Gio.FileInfo.FileInfo) ->      -- out_info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr (Ptr Gio.File.File) ->              -- out_child : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | This is a version of 'GI.Gio.Objects.FileEnumerator.fileEnumeratorNextFile' that\'s easier to
-- use correctly from C programs.  With 'GI.Gio.Objects.FileEnumerator.fileEnumeratorNextFile',
-- the gboolean return value signifies \"end of iteration or error\", which
-- requires allocation of a temporary t'GError'.
-- 
-- In contrast, with this function, a 'P.False' return from
-- 'GI.Gio.Objects.FileEnumerator.fileEnumeratorIterate' *always* means
-- \"error\".  End of iteration is signaled by /@outInfo@/ or /@outChild@/ being 'P.Nothing'.
-- 
-- Another crucial difference is that the references for /@outInfo@/ and
-- /@outChild@/ are owned by /@direnum@/ (they are cached as hidden
-- properties).  You must not unref them in your own code.  This makes
-- memory management significantly easier for C code in combination
-- with loops.
-- 
-- Finally, this function optionally allows retrieving a t'GI.Gio.Interfaces.File.File' as
-- well.
-- 
-- You must specify at least one of /@outInfo@/ or /@outChild@/.
-- 
-- The code pattern for correctly using 'GI.Gio.Objects.FileEnumerator.fileEnumeratorIterate' from C
-- is:
-- 
-- >
-- >direnum = g_file_enumerate_children (file, ...);
-- >while (TRUE)
-- >  {
-- >    GFileInfo *info;
-- >    if (!g_file_enumerator_iterate (direnum, &info, NULL, cancellable, error))
-- >      goto out;
-- >    if (!info)
-- >      break;
-- >    ... do stuff with "info"; do not unref it! ...
-- >  }
-- >
-- >out:
-- >  g_object_unref (direnum); // Note: frees the last @info
-- 
-- 
-- /Since: 2.44/
fileEnumeratorIterate ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@direnum@/: an open t'GI.Gio.Objects.FileEnumerator.FileEnumerator'
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable'
    -> m ((Gio.FileInfo.FileInfo, Gio.File.File))
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
fileEnumeratorIterate :: a -> Maybe b -> m (FileInfo, File)
fileEnumeratorIterate direnum :: a
direnum cancellable :: Maybe b
cancellable = IO (FileInfo, File) -> m (FileInfo, File)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (FileInfo, File) -> m (FileInfo, File))
-> IO (FileInfo, File) -> m (FileInfo, File)
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
direnum' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
direnum
    Ptr (Ptr FileInfo)
outInfo <- IO (Ptr (Ptr FileInfo))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr Gio.FileInfo.FileInfo))
    Ptr (Ptr File)
outChild <- IO (Ptr (Ptr File))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr Gio.File.File))
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO (FileInfo, File) -> IO () -> IO (FileInfo, File)
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr FileEnumerator
-> Ptr (Ptr FileInfo)
-> Ptr (Ptr File)
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CInt
g_file_enumerator_iterate Ptr FileEnumerator
direnum' Ptr (Ptr FileInfo)
outInfo Ptr (Ptr File)
outChild Ptr Cancellable
maybeCancellable
        Ptr FileInfo
outInfo' <- Ptr (Ptr FileInfo) -> IO (Ptr FileInfo)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr FileInfo)
outInfo
        FileInfo
outInfo'' <- ((ManagedPtr FileInfo -> FileInfo) -> Ptr FileInfo -> IO FileInfo
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr FileInfo -> FileInfo
Gio.FileInfo.FileInfo) Ptr FileInfo
outInfo'
        Ptr File
outChild' <- Ptr (Ptr File) -> IO (Ptr File)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr File)
outChild
        File
outChild'' <- ((ManagedPtr File -> File) -> Ptr File -> IO File
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr File -> File
Gio.File.File) Ptr File
outChild'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
direnum
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr (Ptr FileInfo) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr FileInfo)
outInfo
        Ptr (Ptr File) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr File)
outChild
        (FileInfo, File) -> IO (FileInfo, File)
forall (m :: * -> *) a. Monad m => a -> m a
return (FileInfo
outInfo'', File
outChild'')
     ) (do
        Ptr (Ptr FileInfo) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr FileInfo)
outInfo
        Ptr (Ptr File) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr File)
outChild
     )

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorIterateMethodInfo
instance (signature ~ (Maybe (b) -> m ((Gio.FileInfo.FileInfo, Gio.File.File))), MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileEnumeratorIterateMethodInfo a signature where
    overloadedMethod = fileEnumeratorIterate

#endif

-- method FileEnumerator::next_file
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator."
--                 , 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 = "FileInfo" })
-- throws : True
-- Skip return : False

foreign import ccall "g_file_enumerator_next_file" g_file_enumerator_next_file :: 
    Ptr FileEnumerator ->                   -- enumerator : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.FileInfo.FileInfo)

-- | Returns information for the next file in the enumerated object.
-- Will block until the information is available. The t'GI.Gio.Objects.FileInfo.FileInfo'
-- returned from this function will contain attributes that match the
-- attribute string that was passed when the t'GI.Gio.Objects.FileEnumerator.FileEnumerator' was created.
-- 
-- See the documentation of t'GI.Gio.Objects.FileEnumerator.FileEnumerator' for information about the
-- order of returned files.
-- 
-- On error, returns 'P.Nothing' and sets /@error@/ to the error. If the
-- enumerator is at the end, 'P.Nothing' will be returned and /@error@/ will
-- be unset.
fileEnumeratorNextFile ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'.
    -> Maybe (b)
    -- ^ /@cancellable@/: optional t'GI.Gio.Objects.Cancellable.Cancellable' object, 'P.Nothing' to ignore.
    -> m (Maybe Gio.FileInfo.FileInfo)
    -- ^ __Returns:__ A t'GI.Gio.Objects.FileInfo.FileInfo' or 'P.Nothing' on error
    --    or end of enumerator.  Free the returned object with
    --    'GI.GObject.Objects.Object.objectUnref' when no longer needed. /(Can throw 'Data.GI.Base.GError.GError')/
fileEnumeratorNextFile :: a -> Maybe b -> m (Maybe FileInfo)
fileEnumeratorNextFile enumerator :: a
enumerator cancellable :: Maybe b
cancellable = IO (Maybe FileInfo) -> m (Maybe FileInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe FileInfo) -> m (Maybe FileInfo))
-> IO (Maybe FileInfo) -> m (Maybe FileInfo)
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO (Maybe FileInfo) -> IO () -> IO (Maybe FileInfo)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr FileInfo
result <- (Ptr (Ptr GError) -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr (Ptr GError) -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ Ptr FileEnumerator
-> Ptr Cancellable -> Ptr (Ptr GError) -> IO (Ptr FileInfo)
g_file_enumerator_next_file Ptr FileEnumerator
enumerator' Ptr Cancellable
maybeCancellable
        Maybe FileInfo
maybeResult <- Ptr FileInfo
-> (Ptr FileInfo -> IO FileInfo) -> IO (Maybe FileInfo)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr FileInfo
result ((Ptr FileInfo -> IO FileInfo) -> IO (Maybe FileInfo))
-> (Ptr FileInfo -> IO FileInfo) -> IO (Maybe FileInfo)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr FileInfo
result' -> do
            FileInfo
result'' <- ((ManagedPtr FileInfo -> FileInfo) -> Ptr FileInfo -> IO FileInfo
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr FileInfo -> FileInfo
Gio.FileInfo.FileInfo) Ptr FileInfo
result'
            FileInfo -> IO FileInfo
forall (m :: * -> *) a. Monad m => a -> m a
return FileInfo
result''
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Maybe FileInfo -> IO (Maybe FileInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe FileInfo
maybeResult
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorNextFileMethodInfo
instance (signature ~ (Maybe (b) -> m (Maybe Gio.FileInfo.FileInfo)), MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileEnumeratorNextFileMethodInfo a signature where
    overloadedMethod = fileEnumeratorNextFile

#endif

-- method FileEnumerator::next_files_async
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "num_files"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of file info objects to request"
--                 , 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, %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 = 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_enumerator_next_files_async" g_file_enumerator_next_files_async :: 
    Ptr FileEnumerator ->                   -- enumerator : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    Int32 ->                                -- num_files : TBasicType TInt
    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 ()

-- | Request information for a number of files from the enumerator asynchronously.
-- When all i\/o for the operation is finished the /@callback@/ will be called with
-- the requested information.
-- 
-- See the documentation of t'GI.Gio.Objects.FileEnumerator.FileEnumerator' for information about the
-- order of returned files.
-- 
-- The callback can be called with less than /@numFiles@/ files in case of error
-- or at the end of the enumerator. In case of a partial error the callback will
-- be called with any succeeding items and no error, and on the next request the
-- error will be reported. If a request is cancelled the callback will be called
-- with 'GI.Gio.Enums.IOErrorEnumCancelled'.
-- 
-- During an async request no other sync and async calls are allowed, and will
-- result in 'GI.Gio.Enums.IOErrorEnumPending' errors.
-- 
-- Any outstanding i\/o request with higher priority (lower numerical value) will
-- be executed before an outstanding request with lower priority. Default
-- priority is 'GI.GLib.Constants.PRIORITY_DEFAULT'.
fileEnumeratorNextFilesAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'.
    -> Int32
    -- ^ /@numFiles@/: the number of file info objects to request
    -> Int32
    -- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request
    -> Maybe (b)
    -- ^ /@cancellable@/: optional t'GI.Gio.Objects.Cancellable.Cancellable' object, 'P.Nothing' to ignore.
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: a t'GI.Gio.Callbacks.AsyncReadyCallback' to call when the request is satisfied
    -> m ()
fileEnumeratorNextFilesAsync :: a -> Int32 -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
fileEnumeratorNextFilesAsync enumerator :: a
enumerator numFiles :: Int32
numFiles ioPriority :: Int32
ioPriority cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr FileEnumerator
-> Int32
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_enumerator_next_files_async Ptr FileEnumerator
enumerator' Int32
numFiles Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorNextFilesAsyncMethodInfo
instance (signature ~ (Int32 -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) => O.MethodInfo FileEnumeratorNextFilesAsyncMethodInfo a signature where
    overloadedMethod = fileEnumeratorNextFilesAsync

#endif

-- method FileEnumerator::next_files_finish
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator."
--                 , 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
--               (TGList
--                  (TInterface Name { namespace = "Gio" , name = "FileInfo" }))
-- throws : True
-- Skip return : False

foreign import ccall "g_file_enumerator_next_files_finish" g_file_enumerator_next_files_finish :: 
    Ptr FileEnumerator ->                   -- enumerator : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr Gio.FileInfo.FileInfo)))

-- | Finishes the asynchronous operation started with 'GI.Gio.Objects.FileEnumerator.fileEnumeratorNextFilesAsync'.
fileEnumeratorNextFilesFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'.
    -> b
    -- ^ /@result@/: a t'GI.Gio.Interfaces.AsyncResult.AsyncResult'.
    -> m [Gio.FileInfo.FileInfo]
    -- ^ __Returns:__ a t'GI.GLib.Structs.List.List' of @/GFileInfos/@. You must free the list with
    --     @/g_list_free()/@ and unref the infos with 'GI.GObject.Objects.Object.objectUnref' when you\'re
    --     done with them. /(Can throw 'Data.GI.Base.GError.GError')/
fileEnumeratorNextFilesFinish :: a -> b -> m [FileInfo]
fileEnumeratorNextFilesFinish enumerator :: a
enumerator result_ :: b
result_ = IO [FileInfo] -> m [FileInfo]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [FileInfo] -> m [FileInfo]) -> IO [FileInfo] -> m [FileInfo]
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO [FileInfo] -> IO () -> IO [FileInfo]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr FileInfo))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr FileInfo))))
-> IO (Ptr (GList (Ptr FileInfo)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr FileInfo))))
 -> IO (Ptr (GList (Ptr FileInfo))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr FileInfo))))
-> IO (Ptr (GList (Ptr FileInfo)))
forall a b. (a -> b) -> a -> b
$ Ptr FileEnumerator
-> Ptr AsyncResult
-> Ptr (Ptr GError)
-> IO (Ptr (GList (Ptr FileInfo)))
g_file_enumerator_next_files_finish Ptr FileEnumerator
enumerator' Ptr AsyncResult
result_'
        [Ptr FileInfo]
result' <- Ptr (GList (Ptr FileInfo)) -> IO [Ptr FileInfo]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr FileInfo))
result
        [FileInfo]
result'' <- (Ptr FileInfo -> IO FileInfo) -> [Ptr FileInfo] -> IO [FileInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr FileInfo -> FileInfo) -> Ptr FileInfo -> IO FileInfo
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr FileInfo -> FileInfo
Gio.FileInfo.FileInfo) [Ptr FileInfo]
result'
        Ptr (GList (Ptr FileInfo)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr FileInfo))
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        [FileInfo] -> IO [FileInfo]
forall (m :: * -> *) a. Monad m => a -> m a
return [FileInfo]
result''
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorNextFilesFinishMethodInfo
instance (signature ~ (b -> m [Gio.FileInfo.FileInfo]), MonadIO m, IsFileEnumerator a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo FileEnumeratorNextFilesFinishMethodInfo a signature where
    overloadedMethod = fileEnumeratorNextFilesFinish

#endif

-- method FileEnumerator::set_pending
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "enumerator"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "FileEnumerator" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GFileEnumerator."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "pending"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a boolean value." , 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_enumerator_set_pending" g_file_enumerator_set_pending :: 
    Ptr FileEnumerator ->                   -- enumerator : TInterface (Name {namespace = "Gio", name = "FileEnumerator"})
    CInt ->                                 -- pending : TBasicType TBoolean
    IO ()

-- | Sets the file enumerator as having pending operations.
fileEnumeratorSetPending ::
    (B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a) =>
    a
    -- ^ /@enumerator@/: a t'GI.Gio.Objects.FileEnumerator.FileEnumerator'.
    -> Bool
    -- ^ /@pending@/: a boolean value.
    -> m ()
fileEnumeratorSetPending :: a -> Bool -> m ()
fileEnumeratorSetPending enumerator :: a
enumerator pending :: Bool
pending = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr FileEnumerator
enumerator' <- a -> IO (Ptr FileEnumerator)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
enumerator
    let pending' :: CInt
pending' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
pending
    Ptr FileEnumerator -> CInt -> IO ()
g_file_enumerator_set_pending Ptr FileEnumerator
enumerator' CInt
pending'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
enumerator
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data FileEnumeratorSetPendingMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsFileEnumerator a) => O.MethodInfo FileEnumeratorSetPendingMethodInfo a signature where
    overloadedMethod = fileEnumeratorSetPending

#endif