gi-gio-2.0.20: GI/Gio/Objects/FileEnumerator.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
'GI.Gio.Objects.FileEnumerator.FileEnumerator' allows you to operate on a set of @/GFiles/@,
returning a 'GI.Gio.Objects.FileInfo.FileInfo' structure for each file enumerated (e.g.
'GI.Gio.Interfaces.File.fileEnumerateChildren' will return a 'GI.Gio.Objects.FileEnumerator.FileEnumerator' for each
of the children within a directory).
To get the next file\'s information from a '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 'GI.Gio.Objects.FileEnumerator.FileEnumerator', use 'GI.Gio.Objects.FileEnumerator.fileEnumeratorClose', or
its asynchronous version, 'GI.Gio.Objects.FileEnumerator.fileEnumeratorCloseAsync'. Once
a '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'.
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gio.Objects.FileEnumerator
(
-- * Exported types
FileEnumerator(..) ,
IsFileEnumerator ,
toFileEnumerator ,
noFileEnumerator ,
-- * Methods
-- ** close #method:close#
#if ENABLE_OVERLOADING
FileEnumeratorCloseMethodInfo ,
#endif
fileEnumeratorClose ,
-- ** closeAsync #method:closeAsync#
#if ENABLE_OVERLOADING
FileEnumeratorCloseAsyncMethodInfo ,
#endif
fileEnumeratorCloseAsync ,
-- ** closeFinish #method:closeFinish#
#if ENABLE_OVERLOADING
FileEnumeratorCloseFinishMethodInfo ,
#endif
fileEnumeratorCloseFinish ,
-- ** getChild #method:getChild#
#if ENABLE_OVERLOADING
FileEnumeratorGetChildMethodInfo ,
#endif
fileEnumeratorGetChild ,
-- ** getContainer #method:getContainer#
#if ENABLE_OVERLOADING
FileEnumeratorGetContainerMethodInfo ,
#endif
fileEnumeratorGetContainer ,
-- ** hasPending #method:hasPending#
#if ENABLE_OVERLOADING
FileEnumeratorHasPendingMethodInfo ,
#endif
fileEnumeratorHasPending ,
-- ** isClosed #method:isClosed#
#if ENABLE_OVERLOADING
FileEnumeratorIsClosedMethodInfo ,
#endif
fileEnumeratorIsClosed ,
-- ** iterate #method:iterate#
#if ENABLE_OVERLOADING
FileEnumeratorIterateMethodInfo ,
#endif
fileEnumeratorIterate ,
-- ** nextFile #method:nextFile#
#if ENABLE_OVERLOADING
FileEnumeratorNextFileMethodInfo ,
#endif
fileEnumeratorNextFile ,
-- ** nextFilesAsync #method:nextFilesAsync#
#if ENABLE_OVERLOADING
FileEnumeratorNextFilesAsyncMethodInfo ,
#endif
fileEnumeratorNextFilesAsync ,
-- ** nextFilesFinish #method:nextFilesFinish#
#if ENABLE_OVERLOADING
FileEnumeratorNextFilesFinishMethodInfo ,
#endif
fileEnumeratorNextFilesFinish ,
-- ** setPending #method:setPending#
#if ENABLE_OVERLOADING
FileEnumeratorSetPendingMethodInfo ,
#endif
fileEnumeratorSetPending ,
-- * Properties
-- ** container #attr:container#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
FileEnumeratorContainerPropertyInfo ,
#endif
constructFileEnumeratorContainer ,
#if 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.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)
foreign import ccall "g_file_enumerator_get_type"
c_g_file_enumerator_get_type :: IO GType
instance GObject FileEnumerator where
gobjectType = c_g_file_enumerator_get_type
-- | 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 = liftIO . unsafeCastTo FileEnumerator
-- | A convenience alias for `Nothing` :: `Maybe` `FileEnumerator`.
noFileEnumerator :: Maybe FileEnumerator
noFileEnumerator = Nothing
#if 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 "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 (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy 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 val = B.Properties.constructObjectPropertyObject "container" (Just val)
#if ENABLE_OVERLOADING
data FileEnumeratorContainerPropertyInfo
instance AttrInfo FileEnumeratorContainerPropertyInfo where
type AttrAllowedOps FileEnumeratorContainerPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
type AttrSetTypeConstraint FileEnumeratorContainerPropertyInfo = Gio.File.IsFile
type AttrBaseTypeConstraint FileEnumeratorContainerPropertyInfo = IsFileEnumerator
type AttrGetType FileEnumeratorContainerPropertyInfo = ()
type AttrLabel FileEnumeratorContainerPropertyInfo = "container"
type AttrOrigin FileEnumeratorContainerPropertyInfo = FileEnumerator
attrGet _ = undefined
attrSet _ = undefined
attrConstruct _ = constructFileEnumeratorContainer
attrClear _ = undefined
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList FileEnumerator
type instance O.AttributeList FileEnumerator = FileEnumeratorAttributeList
type FileEnumeratorAttributeList = ('[ '("container", FileEnumeratorContainerPropertyInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
fileEnumeratorContainer :: AttrLabelProxy "container"
fileEnumeratorContainer = AttrLabelProxy
#endif
#if 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 'GI.Gio.Objects.FileEnumerator.FileEnumerator'. -}
-> Maybe (b)
{- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
-> m ()
{- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileEnumeratorClose enumerator cancellable = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
_ <- propagateGError $ g_file_enumerator_close enumerator' maybeCancellable
touchManagedPtr enumerator
whenJust cancellable touchManagedPtr
return ()
) (do
return ()
)
#if 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 '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 'GI.Gio.Objects.FileEnumerator.FileEnumerator'. -}
-> 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 ()
fileEnumeratorCloseAsync enumerator ioPriority cancellable callback = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
maybeCallback <- case callback of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jCallback -> do
ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
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_enumerator_close_async enumerator' ioPriority maybeCancellable maybeCallback userData
touchManagedPtr enumerator
whenJust cancellable touchManagedPtr
return ()
#if 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 '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 'False'. If /@cancellable@/ was not '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 'False' will be
returned.
-}
fileEnumeratorCloseFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a, Gio.AsyncResult.IsAsyncResult b) =>
a
{- ^ /@enumerator@/: a 'GI.Gio.Objects.FileEnumerator.FileEnumerator'. -}
-> b
{- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
-> m ()
{- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileEnumeratorCloseFinish enumerator result_ = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
result_' <- unsafeManagedPtrCastPtr result_
onException (do
_ <- propagateGError $ g_file_enumerator_close_finish enumerator' result_'
touchManagedPtr enumerator
touchManagedPtr result_
return ()
) (do
return ()
)
#if 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 '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 'GI.Gio.Objects.FileEnumerator.FileEnumerator' -}
-> b
{- ^ /@info@/: a 'GI.Gio.Objects.FileInfo.FileInfo' gotten from 'GI.Gio.Objects.FileEnumerator.fileEnumeratorNextFile'
or the async equivalents. -}
-> m Gio.File.File
{- ^ __Returns:__ a 'GI.Gio.Interfaces.File.File' for the 'GI.Gio.Objects.FileInfo.FileInfo' passed it. -}
fileEnumeratorGetChild enumerator info = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
info' <- unsafeManagedPtrCastPtr info
result <- g_file_enumerator_get_child enumerator' info'
checkUnexpectedReturnNULL "fileEnumeratorGetChild" result
result' <- (wrapObject Gio.File.File) result
touchManagedPtr enumerator
touchManagedPtr info
return result'
#if 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 'GI.Gio.Interfaces.File.File' container which is being enumerated.
/Since: 2.18/
-}
fileEnumeratorGetContainer ::
(B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a) =>
a
{- ^ /@enumerator@/: a 'GI.Gio.Objects.FileEnumerator.FileEnumerator' -}
-> m Gio.File.File
{- ^ __Returns:__ the 'GI.Gio.Interfaces.File.File' which is being enumerated. -}
fileEnumeratorGetContainer enumerator = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
result <- g_file_enumerator_get_container enumerator'
checkUnexpectedReturnNULL "fileEnumeratorGetContainer" result
result' <- (newObject Gio.File.File) result
touchManagedPtr enumerator
return result'
#if 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 'GI.Gio.Objects.FileEnumerator.FileEnumerator'. -}
-> m Bool
{- ^ __Returns:__ 'True' if the /@enumerator@/ has pending operations. -}
fileEnumeratorHasPending enumerator = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
result <- g_file_enumerator_has_pending enumerator'
let result' = (/= 0) result
touchManagedPtr enumerator
return result'
#if 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 'GI.Gio.Objects.FileEnumerator.FileEnumerator'. -}
-> m Bool
{- ^ __Returns:__ 'True' if the /@enumerator@/ is closed. -}
fileEnumeratorIsClosed enumerator = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
result <- g_file_enumerator_is_closed enumerator'
let result' = (/= 0) result
touchManagedPtr enumerator
return result'
#if 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 'GError'.
In contrast, with this function, a 'False' return from
'GI.Gio.Objects.FileEnumerator.fileEnumeratorIterate' *always* means
\"error\". End of iteration is signaled by /@outInfo@/ or /@outChild@/ being '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 '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 'GI.Gio.Objects.FileEnumerator.FileEnumerator' -}
-> Maybe (b)
{- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' -}
-> m ((Gio.FileInfo.FileInfo, Gio.File.File))
{- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
fileEnumeratorIterate direnum cancellable = liftIO $ do
direnum' <- unsafeManagedPtrCastPtr direnum
outInfo <- allocMem :: IO (Ptr (Ptr Gio.FileInfo.FileInfo))
outChild <- allocMem :: IO (Ptr (Ptr Gio.File.File))
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
_ <- propagateGError $ g_file_enumerator_iterate direnum' outInfo outChild maybeCancellable
outInfo' <- peek outInfo
outInfo'' <- (newObject Gio.FileInfo.FileInfo) outInfo'
outChild' <- peek outChild
outChild'' <- (newObject Gio.File.File) outChild'
touchManagedPtr direnum
whenJust cancellable touchManagedPtr
freeMem outInfo
freeMem outChild
return (outInfo'', outChild'')
) (do
freeMem outInfo
freeMem outChild
)
#if 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 'GI.Gio.Objects.FileInfo.FileInfo'
returned from this function will contain attributes that match the
attribute string that was passed when the 'GI.Gio.Objects.FileEnumerator.FileEnumerator' was created.
See the documentation of 'GI.Gio.Objects.FileEnumerator.FileEnumerator' for information about the
order of returned files.
On error, returns 'Nothing' and sets /@error@/ to the error. If the
enumerator is at the end, 'Nothing' will be returned and /@error@/ will
be unset.
-}
fileEnumeratorNextFile ::
(B.CallStack.HasCallStack, MonadIO m, IsFileEnumerator a, Gio.Cancellable.IsCancellable b) =>
a
{- ^ /@enumerator@/: a 'GI.Gio.Objects.FileEnumerator.FileEnumerator'. -}
-> Maybe (b)
{- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
-> m (Maybe Gio.FileInfo.FileInfo)
{- ^ __Returns:__ A 'GI.Gio.Objects.FileInfo.FileInfo' or '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 enumerator cancellable = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
result <- propagateGError $ g_file_enumerator_next_file enumerator' maybeCancellable
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (wrapObject Gio.FileInfo.FileInfo) result'
return result''
touchManagedPtr enumerator
whenJust cancellable touchManagedPtr
return maybeResult
) (do
return ()
)
#if 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 '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 '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 '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 ()
fileEnumeratorNextFilesAsync enumerator numFiles ioPriority cancellable callback = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
maybeCallback <- case callback of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jCallback -> do
ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
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_enumerator_next_files_async enumerator' numFiles ioPriority maybeCancellable maybeCallback userData
touchManagedPtr enumerator
whenJust cancellable touchManagedPtr
return ()
#if 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 'GI.Gio.Objects.FileEnumerator.FileEnumerator'. -}
-> b
{- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
-> m [Gio.FileInfo.FileInfo]
{- ^ __Returns:__ a '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 enumerator result_ = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
result_' <- unsafeManagedPtrCastPtr result_
onException (do
result <- propagateGError $ g_file_enumerator_next_files_finish enumerator' result_'
result' <- unpackGList result
result'' <- mapM (wrapObject Gio.FileInfo.FileInfo) result'
g_list_free result
touchManagedPtr enumerator
touchManagedPtr result_
return result''
) (do
return ()
)
#if 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 'GI.Gio.Objects.FileEnumerator.FileEnumerator'. -}
-> Bool
{- ^ /@pending@/: a boolean value. -}
-> m ()
fileEnumeratorSetPending enumerator pending = liftIO $ do
enumerator' <- unsafeManagedPtrCastPtr enumerator
let pending' = (fromIntegral . fromEnum) pending
g_file_enumerator_set_pending enumerator' pending'
touchManagedPtr enumerator
return ()
#if ENABLE_OVERLOADING
data FileEnumeratorSetPendingMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsFileEnumerator a) => O.MethodInfo FileEnumeratorSetPendingMethodInfo a signature where
overloadedMethod _ = fileEnumeratorSetPending
#endif