module System.GIO.File.FileEnumerator (
FileEnumerator (..),
FileEnumeratorClass,
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
import System.GIO.Types
fileEnumeratorNextFile :: FileEnumeratorClass enumerator => enumerator
-> Maybe Cancellable
-> IO (Maybe FileInfo)
fileEnumeratorNextFile enumerator cancellable =
checkGError ( \gErrorPtr ->
maybeNull (makeNewGObject mkFileInfo) $
(\(FileEnumerator arg1) (Cancellable arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_file_enumerator_next_file argPtr1 argPtr2 arg3)
(toFileEnumerator enumerator)
(fromMaybe (Cancellable nullForeignPtr) cancellable)
gErrorPtr)
(\ _ -> return Nothing)
fileEnumeratorClose :: FileEnumeratorClass enumerator => enumerator
-> Maybe Cancellable
-> IO ()
fileEnumeratorClose enumerator cancellable =
propagateGError $ \gErrorPtr -> do
(\(FileEnumerator arg1) (Cancellable arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_file_enumerator_close argPtr1 argPtr2 arg3)
(toFileEnumerator enumerator)
(fromMaybe (Cancellable nullForeignPtr) cancellable)
gErrorPtr
return ()
fileEnumeratorNextFilesAsync :: FileEnumeratorClass enumerator
=> enumerator
-> Int
-> Int
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileEnumeratorNextFilesAsync enumerator numFiles ioPriority cancellable callback = do
cCallback <- marshalAsyncReadyCallback callback
(\(FileEnumerator arg1) arg2 arg3 (Cancellable arg4) arg5 arg6 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg4 $ \argPtr4 ->g_file_enumerator_next_files_async argPtr1 arg2 arg3 argPtr4 arg5 arg6)
(toFileEnumerator enumerator)
(fromIntegral numFiles)
(fromIntegral ioPriority)
(fromMaybe (Cancellable nullForeignPtr) cancellable)
cCallback
(castFunPtrToPtr cCallback)
fileEnumeratorNextFilesFinish :: FileEnumeratorClass enumerator => enumerator
-> AsyncResult
-> IO [FileInfo]
fileEnumeratorNextFilesFinish enumerator asyncResult =
propagateGError ((\(FileEnumerator arg1) (AsyncResult arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_file_enumerator_next_files_finish argPtr1 argPtr2 arg3) (toFileEnumerator enumerator) asyncResult)
>>= \glistPtr -> do
infoPtrs <- fromGList glistPtr
mapM (makeNewGObject mkFileInfo . return) infoPtrs
fileEnumeratorCloseAsync :: FileEnumeratorClass enumerator
=> enumerator
-> Int
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
fileEnumeratorCloseAsync enumerator ioPriority mbCancellable callback = do
cCallback <- marshalAsyncReadyCallback callback
(\(FileEnumerator arg1) arg2 (Cancellable arg3) arg4 arg5 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg3 $ \argPtr3 ->g_file_enumerator_close_async argPtr1 arg2 argPtr3 arg4 arg5)
(toFileEnumerator enumerator)
(fromIntegral ioPriority)
(fromMaybe (Cancellable nullForeignPtr) mbCancellable)
cCallback
(castFunPtrToPtr cCallback)
fileEnumeratorCloseFinish :: FileEnumeratorClass enumerator => enumerator
-> AsyncResult
-> IO ()
fileEnumeratorCloseFinish enumerator asyncResult =
propagateGError (\gErrorPtr -> do
(\(FileEnumerator arg1) (AsyncResult arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_file_enumerator_close_finish argPtr1 argPtr2 arg3)
(toFileEnumerator enumerator)
asyncResult
gErrorPtr
return ())
fileEnumeratorIsClosed :: FileEnumeratorClass enumerator => enumerator
-> IO Bool
fileEnumeratorIsClosed enumerator =
liftM toBool $
(\(FileEnumerator arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_enumerator_is_closed argPtr1) (toFileEnumerator enumerator)
fileEnumeratorHasPending :: FileEnumeratorClass enumerator => enumerator
-> IO Bool
fileEnumeratorHasPending enumerator =
liftM toBool $
(\(FileEnumerator arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_enumerator_has_pending argPtr1) (toFileEnumerator enumerator)
fileEnumeratorSetPending :: FileEnumeratorClass enumerator => enumerator
-> Bool
-> IO ()
fileEnumeratorSetPending enumerator pending =
(\(FileEnumerator arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_enumerator_set_pending argPtr1 arg2) (toFileEnumerator enumerator) (fromBool pending)
fileEnumeratorGetContainer :: FileEnumeratorClass enumerator => enumerator
-> IO File
fileEnumeratorGetContainer enumerator =
makeNewGObject mkFile $
(\(FileEnumerator arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_enumerator_get_container argPtr1) (toFileEnumerator 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)))