{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) Information about a specific attribute. -} module GI.Gio.Structs.FileAttributeInfo ( -- * Exported types FileAttributeInfo(..) , newZeroFileAttributeInfo , noFileAttributeInfo , -- * Properties -- ** Flags fileAttributeInfoReadFlags , -- ** Name fileAttributeInfoReadName , -- ** Type fileAttributeInfoReadType , ) 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.Gio.Types import GI.Gio.Callbacks newtype FileAttributeInfo = FileAttributeInfo (ForeignPtr FileAttributeInfo) -- | Construct a `FileAttributeInfo` struct initialized to zero. newZeroFileAttributeInfo :: MonadIO m => m FileAttributeInfo newZeroFileAttributeInfo = liftIO $ callocBytes 16 >>= wrapPtr FileAttributeInfo noFileAttributeInfo :: Maybe FileAttributeInfo noFileAttributeInfo = Nothing fileAttributeInfoReadName :: FileAttributeInfo -> IO T.Text fileAttributeInfoReadName s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 0) :: IO CString val' <- cstringToText val return val' fileAttributeInfoReadType :: FileAttributeInfo -> IO FileAttributeType fileAttributeInfoReadType s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 8) :: IO CUInt let val' = (toEnum . fromIntegral) val return val' fileAttributeInfoReadFlags :: FileAttributeInfo -> IO [FileAttributeInfoFlags] fileAttributeInfoReadFlags s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 12) :: IO CUInt let val' = wordToGFlags val return val' type family ResolveFileAttributeInfoMethod (t :: Symbol) (o :: *) :: * where ResolveFileAttributeInfoMethod l o = MethodResolutionFailed l o instance (info ~ ResolveFileAttributeInfoMethod t FileAttributeInfo, MethodInfo info FileAttributeInfo p) => IsLabelProxy t (FileAttributeInfo -> p) where fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolveFileAttributeInfoMethod t FileAttributeInfo, MethodInfo info FileAttributeInfo p) => IsLabel t (FileAttributeInfo -> p) where fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info) #endif