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

An opaque structure representing an opened directory.
-}

module GI.GLib.Structs.Dir
    ( 

-- * Exported types
    Dir(..)                                 ,
    noDir                                   ,


 -- * Methods
-- ** dirClose
    dirClose                                ,


-- ** dirReadName
    dirReadName                             ,


-- ** dirRewind
    dirRewind                               ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.GLib.Types
import GI.GLib.Callbacks

newtype Dir = Dir (ForeignPtr Dir)
noDir :: Maybe Dir
noDir = Nothing

-- method Dir::close
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Dir", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Dir", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_dir_close" g_dir_close :: 
    Ptr Dir ->                              -- _obj : TInterface "GLib" "Dir"
    IO ()


dirClose ::
    (MonadIO m) =>
    Dir ->                                  -- _obj
    m ()
dirClose _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_dir_close _obj'
    touchManagedPtr _obj
    return ()

-- method Dir::read_name
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Dir", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Dir", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "g_dir_read_name" g_dir_read_name :: 
    Ptr Dir ->                              -- _obj : TInterface "GLib" "Dir"
    IO CString


dirReadName ::
    (MonadIO m) =>
    Dir ->                                  -- _obj
    m T.Text
dirReadName _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_dir_read_name _obj'
    checkUnexpectedReturnNULL "g_dir_read_name" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method Dir::rewind
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Dir", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Dir", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_dir_rewind" g_dir_rewind :: 
    Ptr Dir ->                              -- _obj : TInterface "GLib" "Dir"
    IO ()


dirRewind ::
    (MonadIO m) =>
    Dir ->                                  -- _obj
    m ()
dirRewind _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_dir_rewind _obj'
    touchManagedPtr _obj
    return ()