{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.Dir
(
Dir(..) ,
#if defined(ENABLE_OVERLOADING)
ResolveDirMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
DirCloseMethodInfo ,
#endif
dirClose ,
dirMakeTmp ,
dirOpen ,
#if defined(ENABLE_OVERLOADING)
DirReadNameMethodInfo ,
#endif
dirReadName ,
#if defined(ENABLE_OVERLOADING)
DirRefMethodInfo ,
#endif
dirRef ,
#if defined(ENABLE_OVERLOADING)
DirRewindMethodInfo ,
#endif
dirRewind ,
#if defined(ENABLE_OVERLOADING)
DirUnrefMethodInfo ,
#endif
dirUnref ,
) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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 Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
#else
#endif
newtype Dir = Dir (SP.ManagedPtr Dir)
deriving (Dir -> Dir -> Bool
(Dir -> Dir -> Bool) -> (Dir -> Dir -> Bool) -> Eq Dir
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Dir -> Dir -> Bool
== :: Dir -> Dir -> Bool
$c/= :: Dir -> Dir -> Bool
/= :: Dir -> Dir -> Bool
Eq)
instance SP.ManagedPtrNewtype Dir where
toManagedPtr :: Dir -> ManagedPtr Dir
toManagedPtr (Dir ManagedPtr Dir
p) = ManagedPtr Dir
p
foreign import ccall "g_dir_get_type" c_g_dir_get_type ::
IO GType
type instance O.ParentTypes Dir = '[]
instance O.HasParentTypes Dir
instance B.Types.TypedObject Dir where
glibType :: IO GType
glibType = IO GType
c_g_dir_get_type
instance B.Types.GBoxed Dir
instance B.GValue.IsGValue (Maybe Dir) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_dir_get_type
gvalueSet_ :: Ptr GValue -> Maybe Dir -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Dir
P.Nothing = Ptr GValue -> Ptr Dir -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr Dir
forall a. Ptr a
FP.nullPtr :: FP.Ptr Dir)
gvalueSet_ Ptr GValue
gv (P.Just Dir
obj) = Dir -> (Ptr Dir -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Dir
obj (Ptr GValue -> Ptr Dir -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Dir)
gvalueGet_ Ptr GValue
gv = do
Ptr Dir
ptr <- Ptr GValue -> IO (Ptr Dir)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr Dir)
if Ptr Dir
ptr Ptr Dir -> Ptr Dir -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Dir
forall a. Ptr a
FP.nullPtr
then Dir -> Maybe Dir
forall a. a -> Maybe a
P.Just (Dir -> Maybe Dir) -> IO Dir -> IO (Maybe Dir)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Dir -> Dir) -> Ptr Dir -> IO Dir
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Dir -> Dir
Dir Ptr Dir
ptr
else Maybe Dir -> IO (Maybe Dir)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Dir
forall a. Maybe a
P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Dir
type instance O.AttributeList Dir = DirAttributeList
type DirAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "g_dir_open" g_dir_open ::
CString ->
Word32 ->
Ptr (Ptr GError) ->
IO (Ptr Dir)
dirOpen ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> Word32
-> m Dir
dirOpen :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Word32 -> m Dir
dirOpen Text
path Word32
flags = IO Dir -> m Dir
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Dir -> m Dir) -> IO Dir -> m Dir
forall a b. (a -> b) -> a -> b
$ do
CString
path' <- Text -> IO CString
textToCString Text
path
IO Dir -> IO () -> IO Dir
forall a b. IO a -> IO b -> IO a
onException (do
Ptr Dir
result <- (Ptr (Ptr GError) -> IO (Ptr Dir)) -> IO (Ptr Dir)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Dir)) -> IO (Ptr Dir))
-> (Ptr (Ptr GError) -> IO (Ptr Dir)) -> IO (Ptr Dir)
forall a b. (a -> b) -> a -> b
$ CString -> Word32 -> Ptr (Ptr GError) -> IO (Ptr Dir)
g_dir_open CString
path' Word32
flags
Text -> Ptr Dir -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"dirOpen" Ptr Dir
result
Dir
result' <- ((ManagedPtr Dir -> Dir) -> Ptr Dir -> IO Dir
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Dir -> Dir
Dir) Ptr Dir
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
path'
Dir -> IO Dir
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Dir
result'
) (do
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
path'
)
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_dir_close" g_dir_close ::
Ptr Dir ->
IO ()
dirClose ::
(B.CallStack.HasCallStack, MonadIO m) =>
Dir
-> m ()
dirClose :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Dir -> m ()
dirClose Dir
dir = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Dir
dir' <- Dir -> IO (Ptr Dir)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Dir
dir
Ptr Dir -> IO ()
g_dir_close Ptr Dir
dir'
Dir -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Dir
dir
() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data DirCloseMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod DirCloseMethodInfo Dir signature where
overloadedMethod = dirClose
instance O.OverloadedMethodInfo DirCloseMethodInfo Dir where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Dir.dirClose",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Dir.html#v:dirClose"
})
#endif
foreign import ccall "g_dir_read_name" g_dir_read_name ::
Ptr Dir ->
IO CString
dirReadName ::
(B.CallStack.HasCallStack, MonadIO m) =>
Dir
-> m [Char]
dirReadName :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Dir -> m [Char]
dirReadName Dir
dir = IO [Char] -> m [Char]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
Ptr Dir
dir' <- Dir -> IO (Ptr Dir)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Dir
dir
CString
result <- Ptr Dir -> IO CString
g_dir_read_name Ptr Dir
dir'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"dirReadName" CString
result
[Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
Dir -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Dir
dir
[Char] -> IO [Char]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result'
#if defined(ENABLE_OVERLOADING)
data DirReadNameMethodInfo
instance (signature ~ (m [Char]), MonadIO m) => O.OverloadedMethod DirReadNameMethodInfo Dir signature where
overloadedMethod = dirReadName
instance O.OverloadedMethodInfo DirReadNameMethodInfo Dir where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Dir.dirReadName",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Dir.html#v:dirReadName"
})
#endif
foreign import ccall "g_dir_ref" g_dir_ref ::
Ptr Dir ->
IO (Ptr Dir)
dirRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
Dir
-> m Dir
dirRef :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Dir -> m Dir
dirRef Dir
dir = IO Dir -> m Dir
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Dir -> m Dir) -> IO Dir -> m Dir
forall a b. (a -> b) -> a -> b
$ do
Ptr Dir
dir' <- Dir -> IO (Ptr Dir)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Dir
dir
Ptr Dir
result <- Ptr Dir -> IO (Ptr Dir)
g_dir_ref Ptr Dir
dir'
Text -> Ptr Dir -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"dirRef" Ptr Dir
result
Dir
result' <- ((ManagedPtr Dir -> Dir) -> Ptr Dir -> IO Dir
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Dir -> Dir
Dir) Ptr Dir
result
Dir -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Dir
dir
Dir -> IO Dir
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Dir
result'
#if defined(ENABLE_OVERLOADING)
data DirRefMethodInfo
instance (signature ~ (m Dir), MonadIO m) => O.OverloadedMethod DirRefMethodInfo Dir signature where
overloadedMethod = dirRef
instance O.OverloadedMethodInfo DirRefMethodInfo Dir where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Dir.dirRef",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Dir.html#v:dirRef"
})
#endif
foreign import ccall "g_dir_rewind" g_dir_rewind ::
Ptr Dir ->
IO ()
dirRewind ::
(B.CallStack.HasCallStack, MonadIO m) =>
Dir
-> m ()
dirRewind :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Dir -> m ()
dirRewind Dir
dir = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Dir
dir' <- Dir -> IO (Ptr Dir)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Dir
dir
Ptr Dir -> IO ()
g_dir_rewind Ptr Dir
dir'
Dir -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Dir
dir
() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data DirRewindMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod DirRewindMethodInfo Dir signature where
overloadedMethod = dirRewind
instance O.OverloadedMethodInfo DirRewindMethodInfo Dir where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Dir.dirRewind",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Dir.html#v:dirRewind"
})
#endif
foreign import ccall "g_dir_unref" g_dir_unref ::
Ptr Dir ->
IO ()
dirUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
Dir
-> m ()
dirUnref :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Dir -> m ()
dirUnref Dir
dir = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Dir
dir' <- Dir -> IO (Ptr Dir)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Dir
dir
Ptr Dir -> IO ()
g_dir_unref Ptr Dir
dir'
Dir -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Dir
dir
() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data DirUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod DirUnrefMethodInfo Dir signature where
overloadedMethod = dirUnref
instance O.OverloadedMethodInfo DirUnrefMethodInfo Dir where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Dir.dirUnref",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Dir.html#v:dirUnref"
})
#endif
foreign import ccall "g_dir_make_tmp" g_dir_make_tmp ::
CString ->
Ptr (Ptr GError) ->
IO CString
dirMakeTmp ::
(B.CallStack.HasCallStack, MonadIO m) =>
Maybe ([Char])
-> m [Char]
dirMakeTmp :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe [Char] -> m [Char]
dirMakeTmp Maybe [Char]
tmpl = IO [Char] -> m [Char]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
CString
maybeTmpl <- case Maybe [Char]
tmpl of
Maybe [Char]
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
Just [Char]
jTmpl -> do
CString
jTmpl' <- [Char] -> IO CString
stringToCString [Char]
jTmpl
CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jTmpl'
IO [Char] -> IO () -> IO [Char]
forall a b. IO a -> IO b -> IO a
onException (do
CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO CString
g_dir_make_tmp CString
maybeTmpl
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"dirMakeTmp" CString
result
[Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeTmpl
[Char] -> IO [Char]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result'
) (do
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeTmpl
)
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveDirMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveDirMethod "close" o = DirCloseMethodInfo
ResolveDirMethod "readName" o = DirReadNameMethodInfo
ResolveDirMethod "ref" o = DirRefMethodInfo
ResolveDirMethod "rewind" o = DirRewindMethodInfo
ResolveDirMethod "unref" o = DirUnrefMethodInfo
ResolveDirMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveDirMethod t Dir, O.OverloadedMethod info Dir p) => OL.IsLabel t (Dir -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveDirMethod t Dir, O.OverloadedMethod info Dir p, R.HasField t Dir p) => R.HasField t Dir p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveDirMethod t Dir, O.OverloadedMethodInfo info Dir) => OL.IsLabel t (O.MethodProxy info Dir) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif