module System.GIO.File.ContentType (
contentTypeEquals,
contentTypeIsA,
contentTypeIsUnknown,
contentTypeGetDescription,
contentTypeGetMimeType,
contentTypeGetIcon,
contentTypeCanBeExecutable,
contentTypeFromMimeType,
contentTypeGuess,
contentTypeGuessForTree,
contentTypesGetRegistered,
) where
import Control.Monad
import System.GIO.Enums
import System.Glib.FFI
import System.Glib.Flags
import System.Glib.GError
import System.Glib.GList
import System.Glib.GObject
import System.Glib.UTFString
import System.GIO.Types
contentTypeEquals ::
String
-> String
-> Bool
contentTypeEquals type1 type2 =
toBool $ unsafePerformIO $
withUTFString type1 $ \ type1Ptr ->
withUTFString type2 $ \ type2Ptr ->
g_content_type_equals type1Ptr type2Ptr
contentTypeIsA ::
String
-> String
-> Bool
contentTypeIsA type1 supertype =
toBool $ unsafePerformIO $
withUTFString type1 $ \ type1Ptr ->
withUTFString supertype $ \ supertypePtr ->
g_content_type_equals type1Ptr supertypePtr
contentTypeIsUnknown :: String
-> Bool
contentTypeIsUnknown typ =
toBool $ unsafePerformIO $
withUTFString typ $ \ typPtr ->
g_content_type_is_unknown typPtr
contentTypeGetDescription ::
String
-> String
contentTypeGetDescription typ =
unsafePerformIO $
withUTFString typ $ \ typPtr ->
g_content_type_get_description typPtr
>>= readUTFString
contentTypeGetMimeType ::
String
-> String
contentTypeGetMimeType typ =
unsafePerformIO $
withUTFString typ $ \ typPtr ->
g_content_type_get_mime_type typPtr
>>= readUTFString
contentTypeGetIcon :: String
-> Icon
contentTypeGetIcon typ =
unsafePerformIO $ wrapNewGObject mkIcon $
withUTFString typ $ \ typPtr ->
g_content_type_get_icon typPtr
contentTypeCanBeExecutable :: String
-> Bool
contentTypeCanBeExecutable typ =
toBool $ unsafePerformIO $
withUTFString typ $ \ typPtr ->
g_content_type_can_be_executable typPtr
contentTypeFromMimeType ::
String
-> String
contentTypeFromMimeType mimeType =
unsafePerformIO $
withUTFString mimeType $ \ mimeTypePtr ->
g_content_type_from_mime_type mimeTypePtr
>>= readUTFString
contentTypeGuess :: String
-> String
-> Int
-> IO (Bool, String)
contentTypeGuess filename dat dataSize =
withUTFString filename $ \ filenamePtr ->
withUTFString dat $ \ datPtr ->
alloca $ \ resultUncertainPtr -> do
strPtr <- g_content_type_guess
filenamePtr
(castPtr datPtr)
(fromIntegral dataSize)
(castPtr resultUncertainPtr)
resultUncertain <- peek resultUncertainPtr
str <- readUTFString strPtr
return (resultUncertain, str)
contentTypeGuessForTree :: FileClass file
=> file
-> IO [String]
contentTypeGuessForTree root =
(\(File arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_content_type_guess_for_tree argPtr1) (toFile root)
>>= readUTFStringArray0
contentTypesGetRegistered ::
IO [String]
contentTypesGetRegistered = do
glistPtr <- g_content_types_get_registered
strPtrs <- fromGList glistPtr
mapM readUTFString strPtrs
foreign import ccall safe "g_content_type_equals"
g_content_type_equals :: ((Ptr CChar) -> ((Ptr CChar) -> (IO CInt)))
foreign import ccall safe "g_content_type_is_unknown"
g_content_type_is_unknown :: ((Ptr CChar) -> (IO CInt))
foreign import ccall safe "g_content_type_get_description"
g_content_type_get_description :: ((Ptr CChar) -> (IO (Ptr CChar)))
foreign import ccall safe "g_content_type_get_mime_type"
g_content_type_get_mime_type :: ((Ptr CChar) -> (IO (Ptr CChar)))
foreign import ccall safe "g_content_type_get_icon"
g_content_type_get_icon :: ((Ptr CChar) -> (IO (Ptr Icon)))
foreign import ccall safe "g_content_type_can_be_executable"
g_content_type_can_be_executable :: ((Ptr CChar) -> (IO CInt))
foreign import ccall safe "g_content_type_from_mime_type"
g_content_type_from_mime_type :: ((Ptr CChar) -> (IO (Ptr CChar)))
foreign import ccall safe "g_content_type_guess"
g_content_type_guess :: ((Ptr CChar) -> ((Ptr CUChar) -> (CUInt -> ((Ptr CInt) -> (IO (Ptr CChar))))))
foreign import ccall safe "g_content_type_guess_for_tree"
g_content_type_guess_for_tree :: ((Ptr File) -> (IO (Ptr (Ptr CChar))))
foreign import ccall safe "g_content_types_get_registered"
g_content_types_get_registered :: (IO (Ptr ()))