{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- @GPathBuf@ is a helper type that allows you to easily build paths from
-- individual elements, using the platform specific conventions for path
-- separators.
-- 
-- 
-- === /C code/
-- >
-- >g_auto (GPathBuf) path;
-- >
-- >g_path_buf_init (&path);
-- >
-- >g_path_buf_push (&path, "usr");
-- >g_path_buf_push (&path, "bin");
-- >g_path_buf_push (&path, "echo");
-- >
-- >g_autofree char *echo = g_path_buf_to_path (&path);
-- >g_assert_cmpstr (echo, ==, "/usr/bin/echo");
-- 
-- 
-- You can also load a full path and then operate on its components:
-- 
-- 
-- === /C code/
-- >
-- >g_auto (GPathBuf) path;
-- >
-- >g_path_buf_init_from_path (&path, "/usr/bin/echo");
-- >
-- >g_path_buf_pop (&path);
-- >g_path_buf_push (&path, "sh");
-- >
-- >g_autofree char *sh = g_path_buf_to_path (&path);
-- >g_assert_cmpstr (sh, ==, "/usr/bin/sh");
-- 
-- 
-- @GPathBuf@ is available since GLib 2.76.
-- 
-- /Since: 2.76/

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.GLib.Structs.PathBuf
    ( 

-- * Exported types
    PathBuf(..)                             ,
    newZeroPathBuf                          ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [clear]("GI.GLib.Structs.PathBuf#g:method:clear"), [clearToPath]("GI.GLib.Structs.PathBuf#g:method:clearToPath"), [free]("GI.GLib.Structs.PathBuf#g:method:free"), [freeToPath]("GI.GLib.Structs.PathBuf#g:method:freeToPath"), [init]("GI.GLib.Structs.PathBuf#g:method:init"), [initFromPath]("GI.GLib.Structs.PathBuf#g:method:initFromPath"), [pop]("GI.GLib.Structs.PathBuf#g:method:pop"), [push]("GI.GLib.Structs.PathBuf#g:method:push"), [toPath]("GI.GLib.Structs.PathBuf#g:method:toPath").
-- 
-- ==== Getters
-- /None/.
-- 
-- ==== Setters
-- [setExtension]("GI.GLib.Structs.PathBuf#g:method:setExtension"), [setFilename]("GI.GLib.Structs.PathBuf#g:method:setFilename").

#if defined(ENABLE_OVERLOADING)
    ResolvePathBufMethod                    ,
#endif

-- ** clear #method:clear#

#if defined(ENABLE_OVERLOADING)
    PathBufClearMethodInfo                  ,
#endif
    pathBufClear                            ,


-- ** clearToPath #method:clearToPath#

#if defined(ENABLE_OVERLOADING)
    PathBufClearToPathMethodInfo            ,
#endif
    pathBufClearToPath                      ,


-- ** equal #method:equal#

    pathBufEqual                            ,


-- ** free #method:free#

#if defined(ENABLE_OVERLOADING)
    PathBufFreeMethodInfo                   ,
#endif
    pathBufFree                             ,


-- ** freeToPath #method:freeToPath#

#if defined(ENABLE_OVERLOADING)
    PathBufFreeToPathMethodInfo             ,
#endif
    pathBufFreeToPath                       ,


-- ** init #method:init#

#if defined(ENABLE_OVERLOADING)
    PathBufInitMethodInfo                   ,
#endif
    pathBufInit                             ,


-- ** initFromPath #method:initFromPath#

#if defined(ENABLE_OVERLOADING)
    PathBufInitFromPathMethodInfo           ,
#endif
    pathBufInitFromPath                     ,


-- ** pop #method:pop#

#if defined(ENABLE_OVERLOADING)
    PathBufPopMethodInfo                    ,
#endif
    pathBufPop                              ,


-- ** push #method:push#

#if defined(ENABLE_OVERLOADING)
    PathBufPushMethodInfo                   ,
#endif
    pathBufPush                             ,


-- ** setExtension #method:setExtension#

#if defined(ENABLE_OVERLOADING)
    PathBufSetExtensionMethodInfo           ,
#endif
    pathBufSetExtension                     ,


-- ** setFilename #method:setFilename#

#if defined(ENABLE_OVERLOADING)
    PathBufSetFilenameMethodInfo            ,
#endif
    pathBufSetFilename                      ,


-- ** toPath #method:toPath#

#if defined(ENABLE_OVERLOADING)
    PathBufToPathMethodInfo                 ,
#endif
    pathBufToPath                           ,




    ) 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


-- | Memory-managed wrapper type.
newtype PathBuf = PathBuf (SP.ManagedPtr PathBuf)
    deriving (PathBuf -> PathBuf -> Bool
(PathBuf -> PathBuf -> Bool)
-> (PathBuf -> PathBuf -> Bool) -> Eq PathBuf
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PathBuf -> PathBuf -> Bool
== :: PathBuf -> PathBuf -> Bool
$c/= :: PathBuf -> PathBuf -> Bool
/= :: PathBuf -> PathBuf -> Bool
Eq)

instance SP.ManagedPtrNewtype PathBuf where
    toManagedPtr :: PathBuf -> ManagedPtr PathBuf
toManagedPtr (PathBuf ManagedPtr PathBuf
p) = ManagedPtr PathBuf
p

instance BoxedPtr PathBuf where
    boxedPtrCopy :: PathBuf -> IO PathBuf
boxedPtrCopy = \PathBuf
p -> PathBuf -> (Ptr PathBuf -> IO PathBuf) -> IO PathBuf
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr PathBuf
p (Int -> Ptr PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
64 (Ptr PathBuf -> IO (Ptr PathBuf))
-> (Ptr PathBuf -> IO PathBuf) -> Ptr PathBuf -> IO PathBuf
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr PathBuf -> PathBuf) -> Ptr PathBuf -> IO PathBuf
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr PathBuf -> PathBuf
PathBuf)
    boxedPtrFree :: PathBuf -> IO ()
boxedPtrFree = \PathBuf
x -> PathBuf -> (Ptr PathBuf -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr PathBuf
x Ptr PathBuf -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr PathBuf where
    boxedPtrCalloc :: IO (Ptr PathBuf)
boxedPtrCalloc = Int -> IO (Ptr PathBuf)
forall a. Int -> IO (Ptr a)
callocBytes Int
64


-- | Construct a `PathBuf` struct initialized to zero.
newZeroPathBuf :: MonadIO m => m PathBuf
newZeroPathBuf :: forall (m :: * -> *). MonadIO m => m PathBuf
newZeroPathBuf = IO PathBuf -> m PathBuf
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PathBuf -> m PathBuf) -> IO PathBuf -> m PathBuf
forall a b. (a -> b) -> a -> b
$ IO (Ptr PathBuf)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr PathBuf) -> (Ptr PathBuf -> IO PathBuf) -> IO PathBuf
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr PathBuf -> PathBuf) -> Ptr PathBuf -> IO PathBuf
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr PathBuf -> PathBuf
PathBuf

instance tag ~ 'AttrSet => Constructible PathBuf tag where
    new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr PathBuf -> PathBuf)
-> [AttrOp PathBuf tag] -> m PathBuf
new ManagedPtr PathBuf -> PathBuf
_ [AttrOp PathBuf tag]
attrs = do
        PathBuf
o <- m PathBuf
forall (m :: * -> *). MonadIO m => m PathBuf
newZeroPathBuf
        PathBuf -> [AttrOp PathBuf 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set PathBuf
o [AttrOp PathBuf tag]
[AttrOp PathBuf 'AttrSet]
attrs
        PathBuf -> m PathBuf
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return PathBuf
o



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList PathBuf
type instance O.AttributeList PathBuf = PathBufAttributeList
type PathBufAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

-- method PathBuf::clear
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_clear" g_path_buf_clear :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    IO ()

-- | Clears the contents of the path buffer.
-- 
-- This function should be use to free the resources in a stack-allocated
-- @GPathBuf@ initialized using 'GI.GLib.Structs.PathBuf.pathBufInit' or
-- 'GI.GLib.Structs.PathBuf.pathBufInitFromPath'.
-- 
-- /Since: 2.76/
pathBufClear ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> m ()
pathBufClear :: forall (m :: * -> *). (HasCallStack, MonadIO m) => PathBuf -> m ()
pathBufClear PathBuf
buf = 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 PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    Ptr PathBuf -> IO ()
g_path_buf_clear Ptr PathBuf
buf'
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data PathBufClearMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod PathBufClearMethodInfo PathBuf signature where
    overloadedMethod = pathBufClear

instance O.OverloadedMethodInfo PathBufClearMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufClear",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufClear"
        })


#endif

-- method PathBuf::clear_to_path
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_clear_to_path" g_path_buf_clear_to_path :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    IO CString

-- | Clears the contents of the path buffer and returns the built path.
-- 
-- This function returns @NULL@ if the @GPathBuf@ is empty.
-- 
-- See also: 'GI.GLib.Structs.PathBuf.pathBufToPath'
-- 
-- /Since: 2.76/
pathBufClearToPath ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> m (Maybe [Char])
    -- ^ __Returns:__ the built path
pathBufClearToPath :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PathBuf -> m (Maybe [Char])
pathBufClearToPath PathBuf
buf = IO (Maybe [Char]) -> m (Maybe [Char])
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe [Char]) -> m (Maybe [Char]))
-> IO (Maybe [Char]) -> m (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ do
    Ptr PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    CString
result <- Ptr PathBuf -> IO CString
g_path_buf_clear_to_path Ptr PathBuf
buf'
    Maybe [Char]
maybeResult <- CString -> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO [Char]) -> IO (Maybe [Char]))
-> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        [Char]
result'' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        [Char] -> IO [Char]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result''
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    Maybe [Char] -> IO (Maybe [Char])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [Char]
maybeResult

#if defined(ENABLE_OVERLOADING)
data PathBufClearToPathMethodInfo
instance (signature ~ (m (Maybe [Char])), MonadIO m) => O.OverloadedMethod PathBufClearToPathMethodInfo PathBuf signature where
    overloadedMethod = pathBufClearToPath

instance O.OverloadedMethodInfo PathBufClearToPathMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufClearToPath",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufClearToPath"
        })


#endif

-- method PathBuf::free
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_free" g_path_buf_free :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    IO ()

-- | Frees a @GPathBuf@ allocated by @/g_path_buf_new()/@.
-- 
-- /Since: 2.76/
pathBufFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> m ()
pathBufFree :: forall (m :: * -> *). (HasCallStack, MonadIO m) => PathBuf -> m ()
pathBufFree PathBuf
buf = 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 PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    Ptr PathBuf -> IO ()
g_path_buf_free Ptr PathBuf
buf'
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data PathBufFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod PathBufFreeMethodInfo PathBuf signature where
    overloadedMethod = pathBufFree

instance O.OverloadedMethodInfo PathBufFreeMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufFree",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufFree"
        })


#endif

-- method PathBuf::free_to_path
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_free_to_path" g_path_buf_free_to_path :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    IO CString

-- | Frees a @GPathBuf@ allocated by @/g_path_buf_new()/@, and
-- returns the path inside the buffer.
-- 
-- This function returns @NULL@ if the @GPathBuf@ is empty.
-- 
-- See also: 'GI.GLib.Structs.PathBuf.pathBufToPath'
-- 
-- /Since: 2.76/
pathBufFreeToPath ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> m (Maybe [Char])
    -- ^ __Returns:__ the path
pathBufFreeToPath :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PathBuf -> m (Maybe [Char])
pathBufFreeToPath PathBuf
buf = IO (Maybe [Char]) -> m (Maybe [Char])
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe [Char]) -> m (Maybe [Char]))
-> IO (Maybe [Char]) -> m (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ do
    Ptr PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    CString
result <- Ptr PathBuf -> IO CString
g_path_buf_free_to_path Ptr PathBuf
buf'
    Maybe [Char]
maybeResult <- CString -> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO [Char]) -> IO (Maybe [Char]))
-> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        [Char]
result'' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        [Char] -> IO [Char]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result''
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    Maybe [Char] -> IO (Maybe [Char])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [Char]
maybeResult

#if defined(ENABLE_OVERLOADING)
data PathBufFreeToPathMethodInfo
instance (signature ~ (m (Maybe [Char])), MonadIO m) => O.OverloadedMethod PathBufFreeToPathMethodInfo PathBuf signature where
    overloadedMethod = pathBufFreeToPath

instance O.OverloadedMethodInfo PathBufFreeToPathMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufFreeToPath",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufFreeToPath"
        })


#endif

-- method PathBuf::init
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GLib" , name = "PathBuf" })
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_init" g_path_buf_init :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    IO (Ptr PathBuf)

-- | Initializes a @GPathBuf@ instance.
-- 
-- /Since: 2.76/
pathBufInit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> m PathBuf
    -- ^ __Returns:__ the initialized path builder
pathBufInit :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PathBuf -> m PathBuf
pathBufInit PathBuf
buf = IO PathBuf -> m PathBuf
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PathBuf -> m PathBuf) -> IO PathBuf -> m PathBuf
forall a b. (a -> b) -> a -> b
$ do
    Ptr PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    Ptr PathBuf
result <- Ptr PathBuf -> IO (Ptr PathBuf)
g_path_buf_init Ptr PathBuf
buf'
    Text -> Ptr PathBuf -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"pathBufInit" Ptr PathBuf
result
    PathBuf
result' <- ((ManagedPtr PathBuf -> PathBuf) -> Ptr PathBuf -> IO PathBuf
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr PathBuf -> PathBuf
PathBuf) Ptr PathBuf
result
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    PathBuf -> IO PathBuf
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return PathBuf
result'

#if defined(ENABLE_OVERLOADING)
data PathBufInitMethodInfo
instance (signature ~ (m PathBuf), MonadIO m) => O.OverloadedMethod PathBufInitMethodInfo PathBuf signature where
    overloadedMethod = pathBufInit

instance O.OverloadedMethodInfo PathBufInitMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufInit",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufInit"
        })


#endif

-- method PathBuf::init_from_path
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "path"
--           , argType = TBasicType TFileName
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a file system path" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GLib" , name = "PathBuf" })
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_init_from_path" g_path_buf_init_from_path :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    CString ->                              -- path : TBasicType TFileName
    IO (Ptr PathBuf)

-- | Initializes a @GPathBuf@ instance with the given path.
-- 
-- /Since: 2.76/
pathBufInitFromPath ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> Maybe ([Char])
    -- ^ /@path@/: a file system path
    -> m PathBuf
    -- ^ __Returns:__ the initialized path builder
pathBufInitFromPath :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PathBuf -> Maybe [Char] -> m PathBuf
pathBufInitFromPath PathBuf
buf Maybe [Char]
path = IO PathBuf -> m PathBuf
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PathBuf -> m PathBuf) -> IO PathBuf -> m PathBuf
forall a b. (a -> b) -> a -> b
$ do
    Ptr PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    CString
maybePath <- case Maybe [Char]
path 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]
jPath -> do
            CString
jPath' <- [Char] -> IO CString
stringToCString [Char]
jPath
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jPath'
    Ptr PathBuf
result <- Ptr PathBuf -> CString -> IO (Ptr PathBuf)
g_path_buf_init_from_path Ptr PathBuf
buf' CString
maybePath
    Text -> Ptr PathBuf -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"pathBufInitFromPath" Ptr PathBuf
result
    PathBuf
result' <- ((ManagedPtr PathBuf -> PathBuf) -> Ptr PathBuf -> IO PathBuf
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr PathBuf -> PathBuf
PathBuf) Ptr PathBuf
result
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybePath
    PathBuf -> IO PathBuf
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return PathBuf
result'

#if defined(ENABLE_OVERLOADING)
data PathBufInitFromPathMethodInfo
instance (signature ~ (Maybe ([Char]) -> m PathBuf), MonadIO m) => O.OverloadedMethod PathBufInitFromPathMethodInfo PathBuf signature where
    overloadedMethod = pathBufInitFromPath

instance O.OverloadedMethodInfo PathBufInitFromPathMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufInitFromPath",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufInitFromPath"
        })


#endif

-- method PathBuf::pop
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_pop" g_path_buf_pop :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    IO CInt

-- | Removes the last element of the path buffer.
-- 
-- If there is only one element in the path buffer (for example, @\/@ on
-- Unix-like operating systems or the drive on Windows systems), it will
-- not be removed and 'P.False' will be returned instead.
-- 
-- 
-- === /C code/
-- >
-- >GPathBuf buf, cmp;
-- >
-- >g_path_buf_init_from_path (&buf, "/bin/sh");
-- >
-- >g_path_buf_pop (&buf);
-- >g_path_buf_init_from_path (&cmp, "/bin");
-- >g_assert_true (g_path_buf_equal (&buf, &cmp));
-- >g_path_buf_clear (&cmp);
-- >
-- >g_path_buf_pop (&buf);
-- >g_path_buf_init_from_path (&cmp, "/");
-- >g_assert_true (g_path_buf_equal (&buf, &cmp));
-- >g_path_buf_clear (&cmp);
-- >
-- >g_path_buf_clear (&buf);
-- 
-- 
-- /Since: 2.76/
pathBufPop ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> m Bool
    -- ^ __Returns:__ @TRUE@ if the buffer was modified and @FALSE@ otherwise
pathBufPop :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PathBuf -> m Bool
pathBufPop PathBuf
buf = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    CInt
result <- Ptr PathBuf -> IO CInt
g_path_buf_pop Ptr PathBuf
buf'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PathBufPopMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.OverloadedMethod PathBufPopMethodInfo PathBuf signature where
    overloadedMethod = pathBufPop

instance O.OverloadedMethodInfo PathBufPopMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufPop",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufPop"
        })


#endif

-- method PathBuf::push
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "path"
--           , argType = TBasicType TFileName
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GLib" , name = "PathBuf" })
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_push" g_path_buf_push :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    CString ->                              -- path : TBasicType TFileName
    IO (Ptr PathBuf)

-- | Extends the given path buffer with /@path@/.
-- 
-- If /@path@/ is absolute, it replaces the current path.
-- 
-- If /@path@/ contains a directory separator, the buffer is extended by
-- as many elements the path provides.
-- 
-- On Windows, both forward slashes and backslashes are treated as
-- directory separators. On other platforms, 'GI.GLib.Constants.DIR_SEPARATOR_S' is the
-- only directory separator.
-- 
-- 
-- === /C code/
-- >
-- >GPathBuf buf, cmp;
-- >
-- >g_path_buf_init_from_path (&buf, "/tmp");
-- >g_path_buf_push (&buf, ".X11-unix/X0");
-- >g_path_buf_init_from_path (&cmp, "/tmp/.X11-unix/X0");
-- >g_assert_true (g_path_buf_equal (&buf, &cmp));
-- >g_path_buf_clear (&cmp);
-- >
-- >g_path_buf_push (&buf, "/etc/locale.conf");
-- >g_path_buf_init_from_path (&cmp, "/etc/locale.conf");
-- >g_assert_true (g_path_buf_equal (&buf, &cmp));
-- >g_path_buf_clear (&cmp);
-- >
-- >g_path_buf_clear (&buf);
-- 
-- 
-- /Since: 2.76/
pathBufPush ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> [Char]
    -- ^ /@path@/: a path
    -> m PathBuf
    -- ^ __Returns:__ the same pointer to /@buf@/, for convenience
pathBufPush :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PathBuf -> [Char] -> m PathBuf
pathBufPush PathBuf
buf [Char]
path = IO PathBuf -> m PathBuf
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PathBuf -> m PathBuf) -> IO PathBuf -> m PathBuf
forall a b. (a -> b) -> a -> b
$ do
    Ptr PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    CString
path' <- [Char] -> IO CString
stringToCString [Char]
path
    Ptr PathBuf
result <- Ptr PathBuf -> CString -> IO (Ptr PathBuf)
g_path_buf_push Ptr PathBuf
buf' CString
path'
    Text -> Ptr PathBuf -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"pathBufPush" Ptr PathBuf
result
    PathBuf
result' <- ((ManagedPtr PathBuf -> PathBuf) -> Ptr PathBuf -> IO PathBuf
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr PathBuf -> PathBuf
PathBuf) Ptr PathBuf
result
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
path'
    PathBuf -> IO PathBuf
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return PathBuf
result'

#if defined(ENABLE_OVERLOADING)
data PathBufPushMethodInfo
instance (signature ~ ([Char] -> m PathBuf), MonadIO m) => O.OverloadedMethod PathBufPushMethodInfo PathBuf signature where
    overloadedMethod = pathBufPush

instance O.OverloadedMethodInfo PathBufPushMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufPush",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufPush"
        })


#endif

-- method PathBuf::set_extension
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "extension"
--           , argType = TBasicType TFileName
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the file extension" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_set_extension" g_path_buf_set_extension :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    CString ->                              -- extension : TBasicType TFileName
    IO CInt

-- | Adds an extension to the file name in the path buffer.
-- 
-- If /@extension@/ is @NULL@, the extension will be unset.
-- 
-- If the path buffer does not have a file name set, this function returns
-- @FALSE@ and leaves the path buffer unmodified.
-- 
-- /Since: 2.76/
pathBufSetExtension ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> Maybe ([Char])
    -- ^ /@extension@/: the file extension
    -> m Bool
    -- ^ __Returns:__ @TRUE@ if the extension was replaced, and @FALSE@ otherwise
pathBufSetExtension :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PathBuf -> Maybe [Char] -> m Bool
pathBufSetExtension PathBuf
buf Maybe [Char]
extension = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    CString
maybeExtension <- case Maybe [Char]
extension 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]
jExtension -> do
            CString
jExtension' <- [Char] -> IO CString
stringToCString [Char]
jExtension
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jExtension'
    CInt
result <- Ptr PathBuf -> CString -> IO CInt
g_path_buf_set_extension Ptr PathBuf
buf' CString
maybeExtension
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeExtension
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PathBufSetExtensionMethodInfo
instance (signature ~ (Maybe ([Char]) -> m Bool), MonadIO m) => O.OverloadedMethod PathBufSetExtensionMethodInfo PathBuf signature where
    overloadedMethod = pathBufSetExtension

instance O.OverloadedMethodInfo PathBufSetExtensionMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufSetExtension",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufSetExtension"
        })


#endif

-- method PathBuf::set_filename
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "file_name"
--           , argType = TBasicType TFileName
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the file name in the path"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_set_filename" g_path_buf_set_filename :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    CString ->                              -- file_name : TBasicType TFileName
    IO CInt

-- | Sets the file name of the path.
-- 
-- If the path buffer is empty, the filename is left unset and this
-- function returns @FALSE@.
-- 
-- If the path buffer only contains the root element (on Unix-like operating
-- systems) or the drive (on Windows), this is the equivalent of pushing
-- the new /@fileName@/.
-- 
-- If the path buffer contains a path, this is the equivalent of
-- popping the path buffer and pushing /@fileName@/, creating a
-- sibling of the original path.
-- 
-- 
-- === /C code/
-- >
-- >GPathBuf buf, cmp;
-- >
-- >g_path_buf_init_from_path (&buf, "/");
-- >
-- >g_path_buf_set_filename (&buf, "bar");
-- >g_path_buf_init_from_path (&cmp, "/bar");
-- >g_assert_true (g_path_buf_equal (&buf, &cmp));
-- >g_path_buf_clear (&cmp);
-- >
-- >g_path_buf_set_filename (&buf, "baz.txt");
-- >g_path_buf_init_from_path (&cmp, "/baz.txt");
-- >g_assert_true (g_path_buf_equal (&buf, &cmp);
-- >g_path_buf_clear (&cmp);
-- >
-- >g_path_buf_clear (&buf);
-- 
-- 
-- /Since: 2.76/
pathBufSetFilename ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> [Char]
    -- ^ /@fileName@/: the file name in the path
    -> m Bool
    -- ^ __Returns:__ @TRUE@ if the file name was replaced, and @FALSE@ otherwise
pathBufSetFilename :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PathBuf -> [Char] -> m Bool
pathBufSetFilename PathBuf
buf [Char]
fileName = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    CString
fileName' <- [Char] -> IO CString
stringToCString [Char]
fileName
    CInt
result <- Ptr PathBuf -> CString -> IO CInt
g_path_buf_set_filename Ptr PathBuf
buf' CString
fileName'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fileName'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PathBufSetFilenameMethodInfo
instance (signature ~ ([Char] -> m Bool), MonadIO m) => O.OverloadedMethod PathBufSetFilenameMethodInfo PathBuf signature where
    overloadedMethod = pathBufSetFilename

instance O.OverloadedMethodInfo PathBufSetFilenameMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufSetFilename",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufSetFilename"
        })


#endif

-- method PathBuf::to_path
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "buf"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "PathBuf" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_to_path" g_path_buf_to_path :: 
    Ptr PathBuf ->                          -- buf : TInterface (Name {namespace = "GLib", name = "PathBuf"})
    IO CString

-- | Retrieves the built path from the path buffer.
-- 
-- On Windows, the result contains backslashes as directory separators,
-- even if forward slashes were used in input.
-- 
-- If the path buffer is empty, this function returns @NULL@.
-- 
-- /Since: 2.76/
pathBufToPath ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    PathBuf
    -- ^ /@buf@/: a path buffer
    -> m (Maybe [Char])
    -- ^ __Returns:__ the path
pathBufToPath :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
PathBuf -> m (Maybe [Char])
pathBufToPath PathBuf
buf = IO (Maybe [Char]) -> m (Maybe [Char])
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe [Char]) -> m (Maybe [Char]))
-> IO (Maybe [Char]) -> m (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ do
    Ptr PathBuf
buf' <- PathBuf -> IO (Ptr PathBuf)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PathBuf
buf
    CString
result <- Ptr PathBuf -> IO CString
g_path_buf_to_path Ptr PathBuf
buf'
    Maybe [Char]
maybeResult <- CString -> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO [Char]) -> IO (Maybe [Char]))
-> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        [Char]
result'' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        [Char] -> IO [Char]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result''
    PathBuf -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PathBuf
buf
    Maybe [Char] -> IO (Maybe [Char])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [Char]
maybeResult

#if defined(ENABLE_OVERLOADING)
data PathBufToPathMethodInfo
instance (signature ~ (m (Maybe [Char])), MonadIO m) => O.OverloadedMethod PathBufToPathMethodInfo PathBuf signature where
    overloadedMethod = pathBufToPath

instance O.OverloadedMethodInfo PathBufToPathMethodInfo PathBuf where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.PathBuf.pathBufToPath",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-PathBuf.html#v:pathBufToPath"
        })


#endif

-- method PathBuf::equal
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "v1"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer to compare"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "v2"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a path buffer to compare"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_path_buf_equal" g_path_buf_equal :: 
    Ptr () ->                               -- v1 : TBasicType TPtr
    Ptr () ->                               -- v2 : TBasicType TPtr
    IO CInt

-- | Compares two path buffers for equality and returns @TRUE@
-- if they are equal.
-- 
-- The path inside the paths buffers are not going to be normalized,
-- so @X\/Y\/Z\/A\/..@, @X\/.\/Y\/Z@ and @X\/Y\/Z@ are not going to be considered
-- equal.
-- 
-- This function can be passed to @/g_hash_table_new()/@ as the
-- @key_equal_func@ parameter.
-- 
-- /Since: 2.76/
pathBufEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@v1@/: a path buffer to compare
    -> Ptr ()
    -- ^ /@v2@/: a path buffer to compare
    -> m Bool
    -- ^ __Returns:__ @TRUE@ if the two path buffers are equal,
    --   and @FALSE@ otherwise
pathBufEqual :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Ptr () -> Ptr () -> m Bool
pathBufEqual Ptr ()
v1 Ptr ()
v2 = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Ptr () -> Ptr () -> IO CInt
g_path_buf_equal Ptr ()
v1 Ptr ()
v2
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolvePathBufMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolvePathBufMethod "clear" o = PathBufClearMethodInfo
    ResolvePathBufMethod "clearToPath" o = PathBufClearToPathMethodInfo
    ResolvePathBufMethod "free" o = PathBufFreeMethodInfo
    ResolvePathBufMethod "freeToPath" o = PathBufFreeToPathMethodInfo
    ResolvePathBufMethod "init" o = PathBufInitMethodInfo
    ResolvePathBufMethod "initFromPath" o = PathBufInitFromPathMethodInfo
    ResolvePathBufMethod "pop" o = PathBufPopMethodInfo
    ResolvePathBufMethod "push" o = PathBufPushMethodInfo
    ResolvePathBufMethod "toPath" o = PathBufToPathMethodInfo
    ResolvePathBufMethod "setExtension" o = PathBufSetExtensionMethodInfo
    ResolvePathBufMethod "setFilename" o = PathBufSetFilenameMethodInfo
    ResolvePathBufMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolvePathBufMethod t PathBuf, O.OverloadedMethod info PathBuf p) => OL.IsLabel t (PathBuf -> 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 ~ ResolvePathBufMethod t PathBuf, O.OverloadedMethod info PathBuf p, R.HasField t PathBuf p) => R.HasField t PathBuf p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolvePathBufMethod t PathBuf, O.OverloadedMethodInfo info PathBuf) => OL.IsLabel t (O.MethodProxy info PathBuf) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif