{-# 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 ,
#if defined(ENABLE_OVERLOADING)
DirReadNameMethodInfo ,
#endif
dirReadName ,
#if defined(ENABLE_OVERLOADING)
DirRewindMethodInfo ,
#endif
dirRewind ,
) 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.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
newtype Dir = Dir (SP.ManagedPtr Dir)
deriving (Dir -> Dir -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Dir -> Dir -> Bool
$c/= :: Dir -> Dir -> Bool
== :: Dir -> Dir -> Bool
$c== :: Dir -> Dir -> Bool
Eq)
instance SP.ManagedPtrNewtype Dir where
toManagedPtr :: Dir -> ManagedPtr Dir
toManagedPtr (Dir ManagedPtr Dir
p) = ManagedPtr Dir
p
instance BoxedPtr Dir where
boxedPtrCopy :: Dir -> IO Dir
boxedPtrCopy = forall (m :: * -> *) a. Monad m => a -> m a
return
boxedPtrFree :: Dir -> IO ()
boxedPtrFree = \Dir
_x -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Dir
type instance O.AttributeList Dir = DirAttributeList
type DirAttributeList = ('[ ] :: [(Symbol, *)])
#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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr Dir
dir' <- forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Dir
dir
Ptr Dir -> IO ()
g_dir_close Ptr Dir
dir'
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Dir
dir
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.27/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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr Dir
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'
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"dirReadName" CString
result
[Char]
result' <- HasCallStack => CString -> IO [Char]
cstringToString CString
result
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Dir
dir
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.27/docs/GI-GLib-Structs-Dir.html#v:dirReadName"
})
#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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr Dir
dir' <- forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Dir
dir
Ptr Dir -> IO ()
g_dir_rewind Ptr Dir
dir'
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Dir
dir
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.27/docs/GI-GLib-Structs-Dir.html#v:dirRewind"
})
#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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
CString
maybeTmpl <- case Maybe [Char]
tmpl of
Maybe [Char]
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Ptr a
nullPtr
Just [Char]
jTmpl -> do
CString
jTmpl' <- [Char] -> IO CString
stringToCString [Char]
jTmpl
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jTmpl'
forall a b. IO a -> IO b -> IO a
onException (do
CString
result <- forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO CString
g_dir_make_tmp CString
maybeTmpl
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"dirMakeTmp" CString
result
[Char]
result' <- HasCallStack => CString -> IO [Char]
cstringToString CString
result
forall a. Ptr a -> IO ()
freeMem CString
result
forall a. Ptr a -> IO ()
freeMem CString
maybeTmpl
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result'
) (do
forall a. Ptr a -> IO ()
freeMem CString
maybeTmpl
)
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveDirMethod (t :: Symbol) (o :: *) :: * where
ResolveDirMethod "close" o = DirCloseMethodInfo
ResolveDirMethod "readName" o = DirReadNameMethodInfo
ResolveDirMethod "rewind" o = DirRewindMethodInfo
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