{-# LINE 2 "./System/GIO/File/FileEnumerator.chs" #-}
-- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*-
--
-- Author : Andy Stewart
-- Created: 30-Apirl-2010
--
-- Copyright (c) 2010 Andy Stewart
--
-- This library is free software: you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public License
-- as published by the Free Software Foundation, either version 3 of
-- the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this program. If not, see
-- <http:
--
-- GIO, the C library which this Haskell library depends on, is
-- available under LGPL Version 2. The documentation included with
-- this library is based on the original GIO documentation.
--
-- | Maintainer : gtk2hs-devel@lists.sourceforge.net
-- Stability : alpha
-- Portability : portable (depends on GHC)
module System.GIO.File.FileEnumerator (
-- * Details
--
-- | 'FileEnumerator' allows you to operate on a set of 'File's, returning a 'FileInfo' structure for each
-- file enumerated (e.g. 'fileEnumerateChildren' will return a 'FileEnumerator' for each of the
-- children within a directory).
--
-- To get the next file's information from a 'FileEnumerator', use 'fileEnumeratorNextFile' or its
-- asynchronous version, 'fileEnumeratorNextFilesAsync'. Note that the asynchronous version will
-- return a list of 'FileInfo', whereas the synchronous will only return the next file in the
-- enumerator.
--
-- To close a 'FileEnumerator', use 'fileEnumeratorClose', or its asynchronous version,
-- 'fileEnumeratorCloseAsync'.
--
-- * Types
    FileEnumerator (..),
    FileEnumeratorClass,

-- * Methods
    fileEnumeratorNextFile,
    fileEnumeratorClose,
    fileEnumeratorNextFilesAsync,
    fileEnumeratorNextFilesFinish,
    fileEnumeratorCloseAsync,
    fileEnumeratorCloseFinish,
    fileEnumeratorIsClosed,
    fileEnumeratorHasPending,
    fileEnumeratorSetPending,

    fileEnumeratorGetContainer,

    ) where

import Control.Monad
import Data.Maybe (fromMaybe)
import System.GIO.Enums
import System.Glib.FFI
import System.Glib.Flags
import System.Glib.GError
import System.Glib.GList
import System.Glib.GObject
import System.Glib.UTFString
import System.GIO.Async.AsyncResult
{-# LINE 74 "./System/GIO/File/FileEnumerator.chs" #-}
import System.GIO.Types
{-# LINE 75 "./System/GIO/File/FileEnumerator.chs" #-}


{-# LINE 77 "./System/GIO/File/FileEnumerator.chs" #-}

-- | Returns information for the next file in the enumerated object. Will block until the information is
-- available. The 'FileInfo' returned from this function will contain attributes that match the
-- attribute string that was passed when the 'FileEnumerator' was created.
--
-- On error, a 'GError' is thrown. If the enumerator is at the end, 'Nothing' will be
-- returned.
fileEnumeratorNextFile :: FileEnumeratorClass enumerator => enumerator
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> IO (Maybe FileInfo) -- ^ returns A 'FileInfo' or 'Nothing' on error or end of enumerator.
fileEnumeratorNextFile :: forall enumerator.
FileEnumeratorClass enumerator =>
enumerator -> Maybe Cancellable -> IO (Maybe FileInfo)
fileEnumeratorNextFile enumerator
enumerator Maybe Cancellable
cancellable =
    (Ptr (Ptr ()) -> IO (Maybe FileInfo))
-> (GError -> IO (Maybe FileInfo)) -> IO (Maybe FileInfo)
forall a. (Ptr (Ptr ()) -> IO a) -> (GError -> IO a) -> IO a
checkGError ( \Ptr (Ptr ())
gErrorPtr ->
                      (IO (Ptr FileInfo) -> IO FileInfo)
-> IO (Ptr FileInfo) -> IO (Maybe FileInfo)
forall a. (IO (Ptr a) -> IO a) -> IO (Ptr a) -> IO (Maybe a)
maybeNull ((ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
-> IO (Ptr FileInfo) -> IO FileInfo
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
forall {a}. (ForeignPtr FileInfo -> FileInfo, FinalizerPtr a)
mkFileInfo) (IO (Ptr FileInfo) -> IO (Maybe FileInfo))
-> IO (Ptr FileInfo) -> IO (Maybe FileInfo)
forall a b. (a -> b) -> a -> b
$
                          (\(FileEnumerator ForeignPtr FileEnumerator
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr FileEnumerator
-> (Ptr FileEnumerator -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileEnumerator
arg1 ((Ptr FileEnumerator -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr FileEnumerator -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr FileEnumerator
argPtr1 ->ForeignPtr Cancellable
-> (Ptr Cancellable -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo))
-> (Ptr Cancellable -> IO (Ptr FileInfo)) -> IO (Ptr FileInfo)
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr FileEnumerator
-> Ptr Cancellable -> Ptr (Ptr ()) -> IO (Ptr FileInfo)
g_file_enumerator_next_file Ptr FileEnumerator
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 91 "./System/GIO/File/FileEnumerator.chs" #-}
                            (enumerator -> FileEnumerator
forall o. FileEnumeratorClass o => o -> FileEnumerator
toFileEnumerator enumerator
enumerator)
                            (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
                            Ptr (Ptr ())
gErrorPtr)
                (\ GError
_ -> Maybe FileInfo -> IO (Maybe FileInfo)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe FileInfo
forall a. Maybe a
Nothing)


-- | Releases all resources used by this enumerator, making the enumerator return GIoErrorClosed 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.
--
-- Throws a 'GError' if an error occurs.
fileEnumeratorClose :: FileEnumeratorClass enumerator => enumerator
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> IO ()
fileEnumeratorClose :: forall enumerator.
FileEnumeratorClass enumerator =>
enumerator -> Maybe Cancellable -> IO ()
fileEnumeratorClose enumerator
enumerator Maybe Cancellable
cancellable =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((Ptr (Ptr ()) -> IO ()) -> IO ())
-> (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
gErrorPtr -> do
        (\(FileEnumerator ForeignPtr FileEnumerator
arg1) (Cancellable ForeignPtr Cancellable
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr FileEnumerator
-> (Ptr FileEnumerator -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileEnumerator
arg1 ((Ptr FileEnumerator -> IO CInt) -> IO CInt)
-> (Ptr FileEnumerator -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr FileEnumerator
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO CInt) -> IO CInt)
-> (Ptr Cancellable -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr FileEnumerator -> Ptr Cancellable -> Ptr (Ptr ()) -> IO CInt
g_file_enumerator_close Ptr FileEnumerator
argPtr1 Ptr Cancellable
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 110 "./System/GIO/File/FileEnumerator.chs" #-}
          (enumerator -> FileEnumerator
forall o. FileEnumeratorClass o => o -> FileEnumerator
toFileEnumerator enumerator
enumerator)
          (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
          Ptr (Ptr ())
gErrorPtr
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

-- | 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.
--
-- 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 'IoErrorCancelled'.
--
-- During an async request no other sync and async calls are allowed, and will result in
-- 'IoErrorPending' 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 GPriorityDefault.
fileEnumeratorNextFilesAsync :: FileEnumeratorClass enumerator
 => enumerator
 -> Int -- ^ @numFiles@ the number of file info objects to request
 -> Int -- ^ @ioPriority@ the io priority of the request.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' to call when the request is satisfied
 -> IO ()
fileEnumeratorNextFilesAsync :: forall enumerator.
FileEnumeratorClass enumerator =>
enumerator
-> Int -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO ()
fileEnumeratorNextFilesAsync enumerator
enumerator Int
numFiles Int
ioPriority Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
    GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
    (\(FileEnumerator ForeignPtr FileEnumerator
arg1) CInt
arg2 CInt
arg3 (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr FileEnumerator -> (Ptr FileEnumerator -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileEnumerator
arg1 ((Ptr FileEnumerator -> IO ()) -> IO ())
-> (Ptr FileEnumerator -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FileEnumerator
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr FileEnumerator
-> CInt
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_enumerator_next_files_async Ptr FileEnumerator
argPtr1 CInt
arg2 CInt
arg3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 138 "./System/GIO/File/FileEnumerator.chs" #-}
      (toFileEnumerator enumerator)
      (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
numFiles)
      (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
      (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
      GAsyncReadyCallback
cCallback
      (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes the asynchronous operation started with 'fileEnumeratorNextFilesAsync'.
fileEnumeratorNextFilesFinish :: FileEnumeratorClass enumerator => enumerator
 -> AsyncResult
 -> IO [FileInfo]
fileEnumeratorNextFilesFinish :: forall enumerator.
FileEnumeratorClass enumerator =>
enumerator -> AsyncResult -> IO [FileInfo]
fileEnumeratorNextFilesFinish enumerator
enumerator AsyncResult
asyncResult =
    (Ptr (Ptr ()) -> IO (Ptr ())) -> IO (Ptr ())
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError ((\(FileEnumerator ForeignPtr FileEnumerator
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr FileEnumerator
-> (Ptr FileEnumerator -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileEnumerator
arg1 ((Ptr FileEnumerator -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr FileEnumerator -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr FileEnumerator
argPtr1 ->ForeignPtr AsyncResult
-> (Ptr AsyncResult -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr AsyncResult -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr FileEnumerator
-> Ptr AsyncResult -> Ptr (Ptr ()) -> IO (Ptr ())
g_file_enumerator_next_files_finish Ptr FileEnumerator
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3) (enumerator -> FileEnumerator
forall o. FileEnumeratorClass o => o -> FileEnumerator
toFileEnumerator enumerator
enumerator) AsyncResult
asyncResult)
      IO (Ptr ()) -> (Ptr () -> IO [FileInfo]) -> IO [FileInfo]
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr ()
glistPtr -> do
        [Ptr FileInfo]
infoPtrs <- Ptr () -> IO [Ptr FileInfo]
forall a. Ptr () -> IO [Ptr a]
fromGList Ptr ()
glistPtr
        (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)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
-> IO (Ptr FileInfo) -> IO FileInfo
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr FileInfo -> FileInfo, FinalizerPtr FileInfo)
forall {a}. (ForeignPtr FileInfo -> FileInfo, FinalizerPtr a)
mkFileInfo (IO (Ptr FileInfo) -> IO FileInfo)
-> (Ptr FileInfo -> IO (Ptr FileInfo))
-> Ptr FileInfo
-> IO FileInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr FileInfo -> IO (Ptr FileInfo)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return) [Ptr FileInfo]
infoPtrs

-- | 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 'IoErrorCancelled' will be returned
-- in 'fileEnumeratorCloseFinish'.
fileEnumeratorCloseAsync :: FileEnumeratorClass enumerator
 => enumerator
 -> Int -- ^ @ioPriority@ the I/O priority of the request.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' to call when the request is satisfied
 -> IO ()
fileEnumeratorCloseAsync :: forall enumerator.
FileEnumeratorClass enumerator =>
enumerator
-> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO ()
fileEnumeratorCloseAsync enumerator
enumerator Int
ioPriority Maybe Cancellable
mbCancellable AsyncReadyCallback
callback = do
    GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
    (\(FileEnumerator ForeignPtr FileEnumerator
arg1) CInt
arg2 (Cancellable ForeignPtr Cancellable
arg3) GAsyncReadyCallback
arg4 Ptr ()
arg5 -> ForeignPtr FileEnumerator -> (Ptr FileEnumerator -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileEnumerator
arg1 ((Ptr FileEnumerator -> IO ()) -> IO ())
-> (Ptr FileEnumerator -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FileEnumerator
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg3 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr3 ->Ptr FileEnumerator
-> CInt
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_file_enumerator_close_async Ptr FileEnumerator
argPtr1 CInt
arg2 Ptr Cancellable
argPtr3 GAsyncReadyCallback
arg4 Ptr ()
arg5)
{-# LINE 169 "./System/GIO/File/FileEnumerator.chs" #-}
      (toFileEnumerator enumerator)
      (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ioPriority)
      (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
mbCancellable)
      GAsyncReadyCallback
cCallback
      (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes closing a file enumerator, started from 'fileEnumeratorCloseAsync'.
--
-- If the file enumerator was already closed when 'fileEnumeratorCloseAsync' was called, then this
-- function will report GIoErrorClosed in error, and return 'False'. If the file enumerator had
-- pending operation when the close operation was started, then this function will report
-- 'IoErrorPending', 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 'GError' 'IoErrorCancelled' will be thrown.
fileEnumeratorCloseFinish :: FileEnumeratorClass enumerator => enumerator
 -> AsyncResult
 -> IO ()
fileEnumeratorCloseFinish :: forall enumerator.
FileEnumeratorClass enumerator =>
enumerator -> AsyncResult -> IO ()
fileEnumeratorCloseFinish enumerator
enumerator AsyncResult
asyncResult =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                       (\(FileEnumerator ForeignPtr FileEnumerator
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr FileEnumerator
-> (Ptr FileEnumerator -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileEnumerator
arg1 ((Ptr FileEnumerator -> IO CInt) -> IO CInt)
-> (Ptr FileEnumerator -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr FileEnumerator
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr FileEnumerator -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_file_enumerator_close_finish Ptr FileEnumerator
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 189 "./System/GIO/File/FileEnumerator.chs" #-}
                          (enumerator -> FileEnumerator
forall o. FileEnumeratorClass o => o -> FileEnumerator
toFileEnumerator enumerator
enumerator)
                          AsyncResult
asyncResult
                          Ptr (Ptr ())
gErrorPtr
                       () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Checks if the file enumerator has been closed.
fileEnumeratorIsClosed :: FileEnumeratorClass enumerator => enumerator
 -> IO Bool -- ^ returns 'True' if the enumerator is closed.
fileEnumeratorIsClosed :: forall enumerator.
FileEnumeratorClass enumerator =>
enumerator -> IO Bool
fileEnumeratorIsClosed enumerator
enumerator =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(FileEnumerator ForeignPtr FileEnumerator
arg1) -> ForeignPtr FileEnumerator
-> (Ptr FileEnumerator -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileEnumerator
arg1 ((Ptr FileEnumerator -> IO CInt) -> IO CInt)
-> (Ptr FileEnumerator -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr FileEnumerator
argPtr1 ->Ptr FileEnumerator -> IO CInt
g_file_enumerator_is_closed Ptr FileEnumerator
argPtr1) (enumerator -> FileEnumerator
forall o. FileEnumeratorClass o => o -> FileEnumerator
toFileEnumerator enumerator
enumerator)

-- | Checks if the file enumerator has pending operations.
fileEnumeratorHasPending :: FileEnumeratorClass enumerator => enumerator
 -> IO Bool -- ^ returns 'True' if the enumerator has pending operations.
fileEnumeratorHasPending :: forall enumerator.
FileEnumeratorClass enumerator =>
enumerator -> IO Bool
fileEnumeratorHasPending enumerator
enumerator =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(FileEnumerator ForeignPtr FileEnumerator
arg1) -> ForeignPtr FileEnumerator
-> (Ptr FileEnumerator -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileEnumerator
arg1 ((Ptr FileEnumerator -> IO CInt) -> IO CInt)
-> (Ptr FileEnumerator -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr FileEnumerator
argPtr1 ->Ptr FileEnumerator -> IO CInt
g_file_enumerator_has_pending Ptr FileEnumerator
argPtr1) (enumerator -> FileEnumerator
forall o. FileEnumeratorClass o => o -> FileEnumerator
toFileEnumerator enumerator
enumerator)

-- | Sets the file enumerator as having pending operations.
fileEnumeratorSetPending :: FileEnumeratorClass enumerator => enumerator
 -> Bool
 -> IO ()
fileEnumeratorSetPending :: forall enumerator.
FileEnumeratorClass enumerator =>
enumerator -> Bool -> IO ()
fileEnumeratorSetPending enumerator
enumerator Bool
pending =
  (\(FileEnumerator ForeignPtr FileEnumerator
arg1) CInt
arg2 -> ForeignPtr FileEnumerator -> (Ptr FileEnumerator -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileEnumerator
arg1 ((Ptr FileEnumerator -> IO ()) -> IO ())
-> (Ptr FileEnumerator -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FileEnumerator
argPtr1 ->Ptr FileEnumerator -> CInt -> IO ()
g_file_enumerator_set_pending Ptr FileEnumerator
argPtr1 CInt
arg2) (enumerator -> FileEnumerator
forall o. FileEnumeratorClass o => o -> FileEnumerator
toFileEnumerator enumerator
enumerator) (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
pending)


-- | Get the 'File' container which is being enumerated.
fileEnumeratorGetContainer :: FileEnumeratorClass enumerator => enumerator
 -> IO File
fileEnumeratorGetContainer :: forall enumerator.
FileEnumeratorClass enumerator =>
enumerator -> IO File
fileEnumeratorGetContainer enumerator
enumerator =
    (ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
    (\(FileEnumerator ForeignPtr FileEnumerator
arg1) -> ForeignPtr FileEnumerator
-> (Ptr FileEnumerator -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileEnumerator
arg1 ((Ptr FileEnumerator -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr FileEnumerator -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr FileEnumerator
argPtr1 ->Ptr FileEnumerator -> IO (Ptr File)
g_file_enumerator_get_container Ptr FileEnumerator
argPtr1) (enumerator -> FileEnumerator
forall o. FileEnumeratorClass o => o -> FileEnumerator
toFileEnumerator enumerator
enumerator)

foreign import ccall safe "g_file_enumerator_next_file"
  g_file_enumerator_next_file :: ((Ptr FileEnumerator) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO (Ptr FileInfo)))))

foreign import ccall safe "g_file_enumerator_close"
  g_file_enumerator_close :: ((Ptr FileEnumerator) -> ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_enumerator_next_files_async"
  g_file_enumerator_next_files_async :: ((Ptr FileEnumerator) -> (CInt -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_file_enumerator_next_files_finish"
  g_file_enumerator_next_files_finish :: ((Ptr FileEnumerator) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO (Ptr ())))))

foreign import ccall safe "g_file_enumerator_close_async"
  g_file_enumerator_close_async :: ((Ptr FileEnumerator) -> (CInt -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ()))))))

foreign import ccall safe "g_file_enumerator_close_finish"
  g_file_enumerator_close_finish :: ((Ptr FileEnumerator) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_file_enumerator_is_closed"
  g_file_enumerator_is_closed :: ((Ptr FileEnumerator) -> (IO CInt))

foreign import ccall safe "g_file_enumerator_has_pending"
  g_file_enumerator_has_pending :: ((Ptr FileEnumerator) -> (IO CInt))

foreign import ccall safe "g_file_enumerator_set_pending"
  g_file_enumerator_set_pending :: ((Ptr FileEnumerator) -> (CInt -> (IO ())))

foreign import ccall safe "g_file_enumerator_get_container"
  g_file_enumerator_get_container :: ((Ptr FileEnumerator) -> (IO (Ptr File)))