{-# LINE 2 "./System/GIO/File/FileInfo.chs" #-}
-- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*-
--
-- Author : Andy Stewart
-- Created: 30-Apirl-2010
--
-- Copyright (c) 2010 Andy Stewart
--
-- This library is free software: you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public License
-- as published by the Free Software Foundation, either version 3 of
-- the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this program. If not, see
-- <http:
--
-- GIO, the C library which this Haskell library depends on, is
-- available under LGPL Version 2. The documentation included with
-- this library is based on the original GIO documentation.
--
-- | Maintainer : gtk2hs-devel@lists.sourceforge.net
-- Stability : alpha
-- Portability : portable (depends on GHC)
module System.GIO.File.FileInfo (
-- * Details
--
-- | Functionality for manipulating basic metadata for files. 'FileInfo' implements methods for getting
-- information that all files should contain, and allows for manipulation of extended attributes.
--
-- See 'FileAttribute' for more information on how GIO handles file attributes.
--
-- To obtain a 'FileInfo' for a 'File', use 'fileQueryInfo'. To obtain a
-- 'FileInfo' for a file input or output stream, use 'fileInputStreamQueryInfo' or
-- 'fileOutputStreamQueryInfo'.
--
-- To change the actual attributes of a file, you should then set the attribute in the 'FileInfo' and
-- call 'fileSetAttributesFromInfo' on a 'File'.
--
-- However, not all attributes can be changed in the file. For instance, the actual size of a file
-- cannot be changed via 'fileInfoSetSize' and
-- 'fileQueryWritableNamespaces' to discover the settable attributes of a particular file at
-- runtime.
--
-- 'FileAttributeMatcher' allows for searching through a 'FileInfo' for attributes.

-- * Types
    FileInfo(..),
    FileInfoClass,

-- * Enums,
    FileAttributeStatus (..),

-- * Methods
    fileInfoNew,
    fileInfoDup,
    fileInfoCopyInto,
    fileInfoHasAttribute,

    fileInfoHasNamespace,

    fileInfoListAttributes,
    fileInfoGetAttributeType,
    fileInfoRemoveAttribute,
    fileInfoGetAttributeAsString,
    fileInfoGetAttributeStatus,
    fileInfoGetAttributeString,

    fileInfoGetAttributeStringList,

    fileInfoGetAttributeByteString,
    fileInfoGetAttributeBool,
    fileInfoGetAttributeWord32,
    fileInfoGetAttributeInt32,
    fileInfoGetAttributeWord64,
    fileInfoGetAttributeInt64,
    fileInfoGetAttributeObject,

    fileInfoSetAttributeStatus,

    fileInfoSetAttributeString,

    fileInfoSetAttributeStringList,

    fileInfoSetAttributeByteString,
    fileInfoSetAttributeBool,
    fileInfoSetAttributeWord32,
    fileInfoSetAttributeInt32,
    fileInfoSetAttributeWord64,
    fileInfoSetAttributeInt64,
    fileInfoSetAttributeObject,

    fileInfoClearStatus,
    fileInfoGetFileType,
    fileInfoGetIsHidden,
    fileInfoGetIsBackup,
    fileInfoGetIsSymlink,
    fileInfoGetName,
    fileInfoGetDisplayName,
    fileInfoGetEditName,
    fileInfoGetIcon,
    fileInfoGetContentType,
    fileInfoGetModificationTime,
    fileInfoGetSize,
    fileInfoGetSymlinkTarget,
    fileInfoGetEtag,
    fileInfoGetSortOrder,
    fileInfoUnsetAttributeMask,
    fileInfoSetFileType,
    fileInfoSetIsHidden,
    fileInfoSetIsSymlink,
    fileInfoSetName,
    fileInfoSetDisplayName,
    fileInfoSetEditName,
    fileInfoSetIcon,
    fileInfoSetContentType,
    fileInfoSetModificationTime,
    fileInfoSetSize,

    -- 'fileInfoSetSymlinkTarget' use *static string* that we don't understand the purpose of this function.
    -- If someone know how to use it, uncomment it and fix documentation.
    -- fileInfoSetSymlinkTarget,

    fileInfoSetSortOrder,
    ) where

import Control.Monad

import Data.ByteString (ByteString)
import Data.ByteString (useAsCString)
import Data.ByteString.Unsafe (unsafePackCStringFinalizer)
import System.Glib.FFI
import System.Glib.Flags
import System.Glib.GError
import System.Glib.UTFString
import System.Glib.GObject
import System.Glib.GDateTime

import System.GIO.Enums
import System.GIO.File.FileAttribute
import System.GIO.Types
{-# LINE 147 "./System/GIO/File/FileInfo.chs" #-}


{-# LINE 149 "./System/GIO/File/FileInfo.chs" #-}

-- | Creates a new file info structure.
fileInfoNew :: IO FileInfo
fileInfoNew =
    wrapNewGObject mkFileInfo $
    g_file_info_new
{-# LINE 155 "./System/GIO/File/FileInfo.chs" #-}

-- | Duplicates a file info structure.
fileInfoDup :: FileInfoClass info => info -> IO FileInfo
fileInfoDup info =
    wrapNewGObject mkFileInfo $
    (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_dup argPtr1) (toFileInfo info)

-- | Copies all of the 'FileAttributes' from @srcInfo@ to @destInfo@.
fileInfoCopyInto :: (FileInfoClass srcInfo, FileInfoClass destInfo)
 => srcInfo -- ^ @srcInfo@ source to copy attributes from.
 -> destInfo -- ^ @destInfo@ destination to copy attributes to.
 -> IO ()
fileInfoCopyInto srcInfo destInfo =
  (\(FileInfo arg1) (FileInfo arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_file_info_copy_into argPtr1 argPtr2) (toFileInfo srcInfo) (toFileInfo destInfo)

-- | Checks if a file info structure has an attribute named attribute.
fileInfoHasAttribute :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> Bool -- ^ returns 'True' if Ginfo has an attribute named attribute, 'False' otherwise.
fileInfoHasAttribute info attribute =
  toBool $ unsafePerformIO $
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_has_attribute argPtr1 arg2) (toFileInfo info) attributePtr


-- | Checks if a file info structure has an attribute in the specified @nameSpace@.
fileInfoHasNamespace :: FileInfoClass info => info
 -> String -- ^ @namespace@ a file namespace key.
 -> Bool -- ^ returns 'True' if Ginfo has an namespace named namespace, 'False' otherwise.
fileInfoHasNamespace info namespace =
  toBool $ unsafePerformIO $
  withUTFString namespace $ \ namespacePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_has_namespace argPtr1 arg2) (toFileInfo info) namespacePtr


-- | Lists the file info structure's attributes.
fileInfoListAttributes :: FileInfoClass info => info
 -> String -- ^ @nameSpace@ a file attribute key's namespace.
 -> IO [String]-- ^ returns a array of strings of all of the possible attribute types for the given @nameSpace@
fileInfoListAttributes info nameSpace =
  withUTFString nameSpace $ \ nameSpacePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_list_attributes argPtr1 arg2) (toFileInfo info) nameSpacePtr
  >>= readUTFStringArray0

-- | Gets the attribute type for an attribute key.
fileInfoGetAttributeType :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO FileAttributeType -- ^ returns a 'FileAttributeType' for the given attribute, or 'FileAttributeTypeInvalid' if the key is not set.
fileInfoGetAttributeType info attribute =
  liftM (toEnum . fromIntegral) $
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_type argPtr1 arg2) (toFileInfo info) attributePtr

-- | Removes all cases of attribute from info if it exists.
fileInfoRemoveAttribute :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO ()
fileInfoRemoveAttribute info attribute =
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_remove_attribute argPtr1 arg2) (toFileInfo info) attributePtr

-- | Gets the value of a attribute, formated as a string. This escapes things as needed to make the
-- string valid utf8.
fileInfoGetAttributeAsString :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO String -- ^ returns a UTF-8 string associated with the given attribute.
fileInfoGetAttributeAsString info attribute =
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_as_string argPtr1 arg2) (toFileInfo info) attributePtr
  >>= readUTFString

-- | Gets the attribute status for an attribute key.
fileInfoGetAttributeStatus :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO FileAttributeStatus -- ^ returns a 'FileAttributeStatus' for the given attribute, or 'FileAttributeStatusUnset' if the key is invalid.
fileInfoGetAttributeStatus info attribute =
  liftM (toEnum . fromIntegral) $
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_status argPtr1 arg2) (toFileInfo info) attributePtr

-- | Gets the value of a string attribute.
fileInfoGetAttributeString :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO String -- ^ returns the contents of the attribute value as a string
fileInfoGetAttributeString info attribute =
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_string argPtr1 arg2) (toFileInfo info) attributePtr
  >>= readUTFString


-- | Gets the value of a stringv attribute. If the attribute does not contain a stringv
fileInfoGetAttributeStringList :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO [String] -- ^ returns the contents of the attribute value as a string list
fileInfoGetAttributeStringList info attribute =
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_stringv argPtr1 arg2) (toFileInfo info) attributePtr
  >>= readUTFStringArray0


-- | Gets the value of a byte string attribute.
fileInfoGetAttributeByteString :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO ByteString -- ^ returns the contents of the attribute value as a ByteString
fileInfoGetAttributeByteString info attribute =
  withUTFString attribute $ \ attributePtr -> do
  sPtr <- (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_byte_string argPtr1 arg2) (toFileInfo info) attributePtr
  sLen <- lengthArray0 0 sPtr
  unsafePackCStringFinalizer (castPtr sPtr) (fromIntegral sLen)
        (g_free (castPtr sPtr))

-- | Gets the value of a boolean attribute.
fileInfoGetAttributeBool :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO Bool -- ^ returns the contents of the attribute value as a bool
fileInfoGetAttributeBool info attribute =
  liftM toBool $
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_boolean argPtr1 arg2) (toFileInfo info) attributePtr

-- | Gets an Word32 contained within the attribute.
fileInfoGetAttributeWord32 :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO Word32 -- ^ returns the contents of the attribute value as a bool
fileInfoGetAttributeWord32 info attribute =
  liftM fromIntegral $
  withUTFString attribute $ \ attributePtr -> do
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_uint32 argPtr1 arg2) (toFileInfo info) attributePtr

-- | Gets an Int32 contained within the attribute.
fileInfoGetAttributeInt32 :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO Int32 -- ^ returns the contents of the attribute value as a bool
fileInfoGetAttributeInt32 info attribute =
  liftM fromIntegral $
  withUTFString attribute $ \ attributePtr -> do
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_int32 argPtr1 arg2) (toFileInfo info) attributePtr

-- | Gets an Word64 contained within the attribute.
fileInfoGetAttributeWord64 :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO Word64 -- ^ returns the contents of the attribute value as a bool
fileInfoGetAttributeWord64 info attribute =
  liftM fromIntegral $
  withUTFString attribute $ \ attributePtr -> do
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_uint64 argPtr1 arg2) (toFileInfo info) attributePtr

-- | Gets an Int64 contained within the attribute.
fileInfoGetAttributeInt64 :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO Int64 -- ^ returns the contents of the attribute value as a bool
fileInfoGetAttributeInt64 info attribute =
  liftM fromIntegral $
  withUTFString attribute $ \ attributePtr -> do
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_int64 argPtr1 arg2) (toFileInfo info) attributePtr

-- | Gets the value of a GObject attribute.
fileInfoGetAttributeObject :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> IO (Maybe GObject) -- ^ returns the contents of the attribute value as a object
fileInfoGetAttributeObject info attribute =
  withUTFString attribute $ \ attributePtr ->
    (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_attribute_object argPtr1 arg2) (toFileInfo info) attributePtr
    >>= \x -> maybeNull (makeNewGObject mkGObject) (return $ castPtr x)


-- | Sets the attribute status for an attribute key. This is only needed by external code that implement
-- 'fileSetAttributesFromInfo' or similar functions.
--
-- The attribute must exist in info for this to work. Otherwise 'False' is returned and info is
-- unchanged.
fileInfoSetAttributeStatus :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key
 -> FileAttributeStatus -- ^ @status@ a 'FileAttributeStatus'
 -> IO Bool -- ^ returns 'True' if the status was changed, 'False' if the key was not set.
fileInfoSetAttributeStatus info attribute status =
   liftM toBool $
   withUTFString attribute $ \ attributePtr ->
   (\(FileInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_attribute_status argPtr1 arg2 arg3)
{-# LINE 334 "./System/GIO/File/FileInfo.chs" #-}
     (toFileInfo info)
     attributePtr
     ((fromIntegral . fromEnum) status)


-- | Sets the attribute to contain the given @attrValue@, if possible.
fileInfoSetAttributeString :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> String -- ^ @attrValue@ a string.
 -> IO ()
fileInfoSetAttributeString info attribute attrValue =
  withUTFString attribute $ \ attributePtr ->
  withUTFString attrValue $ \ attrValuePtr ->
  (\(FileInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_attribute_string argPtr1 arg2 arg3) (toFileInfo info) attributePtr attrValuePtr


-- | Sets the attribute to contain the given @attrValue@, if possible.
fileInfoSetAttributeStringList :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> [String] -- ^ @attrValue@ a string.
 -> IO ()
fileInfoSetAttributeStringList info attribute attrValue =
  withUTFString attribute $ \ attributePtr ->
  withUTFStringArray0 attrValue $ \ attrValuePtr ->
  (\(FileInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_attribute_stringv argPtr1 arg2 arg3) (toFileInfo info) attributePtr attrValuePtr


-- | Sets the attribute to contain the given @attrValue@, if possible.
fileInfoSetAttributeByteString :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> ByteString -- ^ @attrValue@ a string.
 -> IO ()
fileInfoSetAttributeByteString info attribute attrValue =
  withUTFString attribute $ \ attributePtr ->
  useAsCString attrValue $ \ attrValuePtr ->
  (\(FileInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_attribute_byte_string argPtr1 arg2 arg3) (toFileInfo info) attributePtr attrValuePtr

-- | Sets the attribute to contain the given @attrValue@, if possible.
fileInfoSetAttributeBool :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> Bool -- ^ @attrValue@ a string.
 -> IO ()
fileInfoSetAttributeBool info attribute attrValue =
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_attribute_boolean argPtr1 arg2 arg3) (toFileInfo info) attributePtr (fromBool attrValue)

-- | Sets the attribute to contain the given @attrValue@, if possible.
fileInfoSetAttributeWord32 :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> Word32 -- ^ @attrValue@ an Word32
 -> IO ()
fileInfoSetAttributeWord32 info attribute attrValue =
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_attribute_uint32 argPtr1 arg2 arg3) (toFileInfo info) attributePtr (fromIntegral attrValue)

-- | Sets the attribute to contain the given @attrValue@, if possible.
fileInfoSetAttributeInt32 :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> Int32 -- ^ @attrValue@ an Int32
 -> IO ()
fileInfoSetAttributeInt32 info attribute attrValue =
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_attribute_int32 argPtr1 arg2 arg3) (toFileInfo info) attributePtr (fromIntegral attrValue)

-- | Sets the attribute to contain the given @attrValue@, if possible.
fileInfoSetAttributeWord64 :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> Word64 -- ^ @attrValue@ an Word64
 -> IO ()
fileInfoSetAttributeWord64 info attribute attrValue =
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_attribute_uint64 argPtr1 arg2 arg3) (toFileInfo info) attributePtr (fromIntegral attrValue)

-- | Sets the attribute to contain the given @attrValue@, if possible.
fileInfoSetAttributeInt64 :: FileInfoClass info => info
 -> String -- ^ @attribute@ a file attribute key.
 -> Int64 -- ^ @attrValue@ an Int64
 -> IO ()
fileInfoSetAttributeInt64 info attribute attrValue =
  withUTFString attribute $ \ attributePtr ->
  (\(FileInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_attribute_int64 argPtr1 arg2 arg3) (toFileInfo info) attributePtr (fromIntegral attrValue)

-- | Sets the attribute to contain the given @attrValue@, if possible.
fileInfoSetAttributeObject :: FileInfoClass info => info
 -> String
 -> GObject
 -> IO ()
fileInfoSetAttributeObject info attribute (GObject attrValue) =
  withUTFString attribute $ \ attributePtr ->
  withForeignPtr attrValue $ \attrValuePtr ->
  (\(FileInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_attribute_object argPtr1 arg2 arg3) (toFileInfo info) attributePtr (castPtr attrValuePtr)

-- | Clears the status information from info.
--
fileInfoClearStatus :: FileInfoClass info => info -> IO ()
fileInfoClearStatus info =
  (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_clear_status argPtr1) (toFileInfo info)

-- | Gets a file's type (whether it is a regular file, symlink, etc). This is different from the file's
-- content type, see 'fileInfoGetContentType'.
--
fileInfoGetFileType :: FileInfoClass info => info
                    -> FileType -- ^ returns a 'FileType' for the given file.
fileInfoGetFileType info =
    (toEnum . fromIntegral) $ unsafePerformIO $
        (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_file_type argPtr1) (toFileInfo info)

-- | Checks if a file is hidden.
fileInfoGetIsHidden :: FileInfoClass info => info
                    -> Bool -- ^ returns 'True' if the file is a hidden file, 'False' otherwise.
fileInfoGetIsHidden info =
    toBool $ unsafePerformIO $
          (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_is_hidden argPtr1) (toFileInfo info)

-- | Checks if a file is a backup file.
fileInfoGetIsBackup :: FileInfoClass info => info
                    -> Bool -- ^ returns 'True' if the file is a backup file, 'False' otherwise.
fileInfoGetIsBackup info =
    toBool $ unsafePerformIO $
          (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_is_backup argPtr1) (toFileInfo info)

-- | Checks if a file is a symlink file.
fileInfoGetIsSymlink :: FileInfoClass info => info
                    -> Bool -- ^ returns 'True' if the file is a symlink file, 'False' otherwise.
fileInfoGetIsSymlink info =
    toBool $ unsafePerformIO $
          (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_is_symlink argPtr1) (toFileInfo info)

-- | Gets the name for a file.
fileInfoGetName :: FileInfoClass info => info
                -> Maybe ByteString -- ^ returns a string containing the file name.
fileInfoGetName info =
    unsafePerformIO $ do
    sPtr <- (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_name argPtr1) (toFileInfo info)
    if sPtr == nullPtr
       then return Nothing
       else do
         sLen <- lengthArray0 0 sPtr
         liftM Just $ unsafePackCStringFinalizer (castPtr sPtr) (fromIntegral sLen)
                          (g_free (castPtr sPtr))

-- | Gets the display name for a file.
fileInfoGetDisplayName :: FileInfoClass info => info
                -> Maybe String -- ^ returns a string containing the display name.
fileInfoGetDisplayName info =
    unsafePerformIO $
    (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_display_name argPtr1) (toFileInfo info)
    >>= maybePeek readUTFString

-- | Gets the edit name for a file.
fileInfoGetEditName :: FileInfoClass info => info
                -> Maybe String -- ^ returns a string containing the edit name.
fileInfoGetEditName info =
    unsafePerformIO $
    (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_edit_name argPtr1) (toFileInfo info)
    >>= maybePeek readUTFString

-- | Gets the icon for a file.
fileInfoGetIcon :: FileInfoClass info => info
                -> IO Icon -- ^ returns 'Icon' for the given info.
fileInfoGetIcon info =
    makeNewGObject mkIcon $
    (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_icon argPtr1) (toFileInfo info)

-- | Gets the file's content type.
fileInfoGetContentType :: FileInfoClass info => info
                       -> Maybe String -- ^ returns a string containing the file's content type. 
fileInfoGetContentType info =
  unsafePerformIO $
  (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_content_type argPtr1) (toFileInfo info)
  >>= maybePeek peekUTFString

-- | Gets the modification time of the current info and sets it in result.
fileInfoGetModificationTime :: FileInfoClass info => info
 -> GTimeVal
fileInfoGetModificationTime info =
  unsafePerformIO $
  alloca $ \ timeValPtr -> do
     (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_modification_time argPtr1 arg2) (toFileInfo info) (castPtr timeValPtr)
     peek timeValPtr

-- | Gets the file's size.
fileInfoGetSize :: FileInfoClass info => info
                -> Int64 -- ^ returns a 'Offset' containing the file's size. 
fileInfoGetSize info =
  fromIntegral $ unsafePerformIO $
  (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_size argPtr1) (toFileInfo info)

-- | Gets the symlink target for a given 'FileInfo'.
fileInfoGetSymlinkTarget :: FileInfoClass info => info
                         -> Maybe String -- ^ returns a string containing the symlink target.
fileInfoGetSymlinkTarget info =
  unsafePerformIO $
  (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_symlink_target argPtr1) (toFileInfo info)
  >>= maybePeek readUTFString

-- | Gets the entity tag for a given 'FileInfo'. See 'FileAttributeEtagValue'.
fileInfoGetEtag :: FileInfoClass info => info
                -> Maybe String -- ^ returns a string containing the value of the "etag:value" attribute.
fileInfoGetEtag info =
  unsafePerformIO $
  (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_etag argPtr1) (toFileInfo info)
  >>= maybePeek readUTFString

-- | Gets the value of the @sortOrder@ attribute from the 'FileInfo'. See
-- 'FileAttributeStandardSortOrder'.
fileInfoGetSortOrder :: FileInfoClass info => info
                     -> Int -- ^ returns the value of the \"standard::sort_order\" attribute.
fileInfoGetSortOrder info =
  fromIntegral $ unsafePerformIO $
  (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_get_sort_order argPtr1) (toFileInfo info)

-- | Unsets a mask set by 'fileInfoSetAttributeMask', if one is set.
fileInfoUnsetAttributeMask :: FileInfoClass info => info -> IO ()
fileInfoUnsetAttributeMask info =
  (\(FileInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_unset_attribute_mask argPtr1) (toFileInfo info)

-- | Sets the file type in a 'FileInfo' to type. See 'FileAttributeStandardType'.
fileInfoSetFileType :: FileInfoClass info => info -> FileType -> IO ()
fileInfoSetFileType info fType =
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_file_type argPtr1 arg2)
{-# LINE 555 "./System/GIO/File/FileInfo.chs" #-}
  (toFileInfo info)
  ((fromIntegral . fromEnum) fType)

-- | Sets the @isHidden@ attribute in a 'FileInfo' according to @isSymlink@. See
-- 'FileAttributeStandardIsHidden'.
fileInfoSetIsHidden :: FileInfoClass info => info -> Bool -> IO ()
fileInfoSetIsHidden info isHidden =
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_is_hidden argPtr1 arg2) (toFileInfo info) (fromBool isHidden)

-- | Sets the @isSymlink@ attribute in a 'FileInfo' according to @isSymlink@. See
-- 'FileAttributeStandardIsSymlink'.
fileInfoSetIsSymlink :: FileInfoClass info => info -> Bool -> IO ()
fileInfoSetIsSymlink info isSymlink =
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_is_symlink argPtr1 arg2) (toFileInfo info) (fromBool isSymlink)

-- | Sets the name attribute for the current 'FileInfo'. See 'FileAttributeStandardName'.
fileInfoSetName :: FileInfoClass info => info -> ByteString -> IO ()
fileInfoSetName info name =
  useAsCString name $ \ namePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_name argPtr1 arg2) (toFileInfo info) namePtr

-- | Sets the display name for the current 'FileInfo'. See 'FileAttributeStandardDisplayName'.
fileInfoSetDisplayName :: FileInfoClass info => info -> String -> IO ()
fileInfoSetDisplayName info displayName =
  withUTFString displayName $ \ displayNamePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_display_name argPtr1 arg2) (toFileInfo info) displayNamePtr

-- | Sets the edit name for the current 'FileInfo'. See 'FileAttributeStandardEditName'.
fileInfoSetEditName :: FileInfoClass info => info -> String -> IO ()
fileInfoSetEditName info editName =
  withUTFString editName $ \ editNamePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_edit_name argPtr1 arg2) (toFileInfo info) editNamePtr

-- | Sets the icon for a given 'FileInfo'. See 'FileAttributeStandardIcon'.
fileInfoSetIcon :: FileInfoClass info => info -> Icon -> IO ()
fileInfoSetIcon info icon =
    (\(FileInfo arg1) (Icon arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_file_info_set_icon argPtr1 argPtr2) (toFileInfo info) (toIcon icon)

-- | Sets the content type attribute for a given 'FileInfo'. See 'FileAttributeStandardContentType'.
fileInfoSetContentType :: FileInfoClass info => info
                       -> String -- ^ @contentType@ a content type. See GContentType.
                       -> IO ()
fileInfoSetContentType info contentType =
  withUTFString contentType $ \ contentTypePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_content_type argPtr1 arg2) (toFileInfo info) contentTypePtr

-- | Sets the 'FileAttributeTimeModified' attribute in the file info to the given time value.
fileInfoSetModificationTime :: FileInfoClass info => info
 -> GTimeVal
 -> IO ()
fileInfoSetModificationTime info mtime =
  with mtime $ \ mtimePtr ->
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_modification_time argPtr1 arg2) (toFileInfo info) (castPtr mtimePtr)

-- | Sets the 'FileAttributeStandardSize' attribute in the file info to the given size.
fileInfoSetSize :: FileInfoClass info => info
                -> Int64 -- ^ @size@ a goffset containing the file's size. 
                -> IO ()
fileInfoSetSize info size =
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_size argPtr1 arg2) (toFileInfo info) (fromIntegral size)

-- | Sets the 'FileAttributeStandardSymlinkTarget' attribute in the file info to the given symlink
-- target.
-- fileInfoSetSymlinkTarget :: FileInfoClass info => info
-- -> String -- ^ @symlinkTarget@ a static string containing a path to a symlink target.
-- -> IO ()
-- fileInfoSetSymlinkTarget info symlinkTarget =
-- withUTFString symlinkTarget $ \ symlinkTargetPtr ->
-- {#call g_file_info_set_symlink_target#} (toFileInfo info) symlinkTargetPtr

-- | Sets the sort order attribute in the file info structure. See 'FileAttributeStandardSortOrder'.
fileInfoSetSortOrder :: FileInfoClass info => info
                     -> Int -- ^ @sortOrder@ a sort order integer.
                     -> IO ()
fileInfoSetSortOrder info sortOrder =
  (\(FileInfo arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_file_info_set_sort_order argPtr1 arg2) (toFileInfo info) (fromIntegral sortOrder)

foreign import ccall safe "g_file_info_new"
  g_file_info_new :: (IO (Ptr FileInfo))

foreign import ccall safe "g_file_info_dup"
  g_file_info_dup :: ((Ptr FileInfo) -> (IO (Ptr FileInfo)))

foreign import ccall safe "g_file_info_copy_into"
  g_file_info_copy_into :: ((Ptr FileInfo) -> ((Ptr FileInfo) -> (IO ())))

foreign import ccall safe "g_file_info_has_attribute"
  g_file_info_has_attribute :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "g_file_info_has_namespace"
  g_file_info_has_namespace :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "g_file_info_list_attributes"
  g_file_info_list_attributes :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO (Ptr (Ptr CChar)))))

foreign import ccall safe "g_file_info_get_attribute_type"
  g_file_info_get_attribute_type :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "g_file_info_remove_attribute"
  g_file_info_remove_attribute :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "g_file_info_get_attribute_as_string"
  g_file_info_get_attribute_as_string :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO (Ptr CChar))))

foreign import ccall safe "g_file_info_get_attribute_status"
  g_file_info_get_attribute_status :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "g_file_info_get_attribute_string"
  g_file_info_get_attribute_string :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO (Ptr CChar))))

foreign import ccall safe "g_file_info_get_attribute_stringv"
  g_file_info_get_attribute_stringv :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO (Ptr (Ptr CChar)))))

foreign import ccall safe "g_file_info_get_attribute_byte_string"
  g_file_info_get_attribute_byte_string :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO (Ptr CChar))))

foreign import ccall unsafe "g_free"
  g_free :: ((Ptr ()) -> (IO ()))

foreign import ccall safe "g_file_info_get_attribute_boolean"
  g_file_info_get_attribute_boolean :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "g_file_info_get_attribute_uint32"
  g_file_info_get_attribute_uint32 :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO CUInt)))

foreign import ccall safe "g_file_info_get_attribute_int32"
  g_file_info_get_attribute_int32 :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "g_file_info_get_attribute_uint64"
  g_file_info_get_attribute_uint64 :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO CULLong)))

foreign import ccall safe "g_file_info_get_attribute_int64"
  g_file_info_get_attribute_int64 :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO CLLong)))

foreign import ccall safe "g_file_info_get_attribute_object"
  g_file_info_get_attribute_object :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO (Ptr ()))))

foreign import ccall safe "g_file_info_set_attribute_status"
  g_file_info_set_attribute_status :: ((Ptr FileInfo) -> ((Ptr CChar) -> (CInt -> (IO CInt))))

foreign import ccall safe "g_file_info_set_attribute_string"
  g_file_info_set_attribute_string :: ((Ptr FileInfo) -> ((Ptr CChar) -> ((Ptr CChar) -> (IO ()))))

foreign import ccall safe "g_file_info_set_attribute_stringv"
  g_file_info_set_attribute_stringv :: ((Ptr FileInfo) -> ((Ptr CChar) -> ((Ptr (Ptr CChar)) -> (IO ()))))

foreign import ccall safe "g_file_info_set_attribute_byte_string"
  g_file_info_set_attribute_byte_string :: ((Ptr FileInfo) -> ((Ptr CChar) -> ((Ptr CChar) -> (IO ()))))

foreign import ccall safe "g_file_info_set_attribute_boolean"
  g_file_info_set_attribute_boolean :: ((Ptr FileInfo) -> ((Ptr CChar) -> (CInt -> (IO ()))))

foreign import ccall safe "g_file_info_set_attribute_uint32"
  g_file_info_set_attribute_uint32 :: ((Ptr FileInfo) -> ((Ptr CChar) -> (CUInt -> (IO ()))))

foreign import ccall safe "g_file_info_set_attribute_int32"
  g_file_info_set_attribute_int32 :: ((Ptr FileInfo) -> ((Ptr CChar) -> (CInt -> (IO ()))))

foreign import ccall safe "g_file_info_set_attribute_uint64"
  g_file_info_set_attribute_uint64 :: ((Ptr FileInfo) -> ((Ptr CChar) -> (CULLong -> (IO ()))))

foreign import ccall safe "g_file_info_set_attribute_int64"
  g_file_info_set_attribute_int64 :: ((Ptr FileInfo) -> ((Ptr CChar) -> (CLLong -> (IO ()))))

foreign import ccall safe "g_file_info_set_attribute_object"
  g_file_info_set_attribute_object :: ((Ptr FileInfo) -> ((Ptr CChar) -> ((Ptr ()) -> (IO ()))))

foreign import ccall safe "g_file_info_clear_status"
  g_file_info_clear_status :: ((Ptr FileInfo) -> (IO ()))

foreign import ccall safe "g_file_info_get_file_type"
  g_file_info_get_file_type :: ((Ptr FileInfo) -> (IO CInt))

foreign import ccall safe "g_file_info_get_is_hidden"
  g_file_info_get_is_hidden :: ((Ptr FileInfo) -> (IO CInt))

foreign import ccall safe "g_file_info_get_is_backup"
  g_file_info_get_is_backup :: ((Ptr FileInfo) -> (IO CInt))

foreign import ccall safe "g_file_info_get_is_symlink"
  g_file_info_get_is_symlink :: ((Ptr FileInfo) -> (IO CInt))

foreign import ccall safe "g_file_info_get_name"
  g_file_info_get_name :: ((Ptr FileInfo) -> (IO (Ptr CChar)))

foreign import ccall safe "g_file_info_get_display_name"
  g_file_info_get_display_name :: ((Ptr FileInfo) -> (IO (Ptr CChar)))

foreign import ccall safe "g_file_info_get_edit_name"
  g_file_info_get_edit_name :: ((Ptr FileInfo) -> (IO (Ptr CChar)))

foreign import ccall safe "g_file_info_get_icon"
  g_file_info_get_icon :: ((Ptr FileInfo) -> (IO (Ptr Icon)))

foreign import ccall safe "g_file_info_get_content_type"
  g_file_info_get_content_type :: ((Ptr FileInfo) -> (IO (Ptr CChar)))

foreign import ccall safe "g_file_info_get_modification_time"
  g_file_info_get_modification_time :: ((Ptr FileInfo) -> ((Ptr ()) -> (IO ())))

foreign import ccall safe "g_file_info_get_size"
  g_file_info_get_size :: ((Ptr FileInfo) -> (IO CLLong))

foreign import ccall safe "g_file_info_get_symlink_target"
  g_file_info_get_symlink_target :: ((Ptr FileInfo) -> (IO (Ptr CChar)))

foreign import ccall safe "g_file_info_get_etag"
  g_file_info_get_etag :: ((Ptr FileInfo) -> (IO (Ptr CChar)))

foreign import ccall safe "g_file_info_get_sort_order"
  g_file_info_get_sort_order :: ((Ptr FileInfo) -> (IO CInt))

foreign import ccall safe "g_file_info_unset_attribute_mask"
  g_file_info_unset_attribute_mask :: ((Ptr FileInfo) -> (IO ()))

foreign import ccall safe "g_file_info_set_file_type"
  g_file_info_set_file_type :: ((Ptr FileInfo) -> (CInt -> (IO ())))

foreign import ccall safe "g_file_info_set_is_hidden"
  g_file_info_set_is_hidden :: ((Ptr FileInfo) -> (CInt -> (IO ())))

foreign import ccall safe "g_file_info_set_is_symlink"
  g_file_info_set_is_symlink :: ((Ptr FileInfo) -> (CInt -> (IO ())))

foreign import ccall safe "g_file_info_set_name"
  g_file_info_set_name :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "g_file_info_set_display_name"
  g_file_info_set_display_name :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "g_file_info_set_edit_name"
  g_file_info_set_edit_name :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "g_file_info_set_icon"
  g_file_info_set_icon :: ((Ptr FileInfo) -> ((Ptr Icon) -> (IO ())))

foreign import ccall safe "g_file_info_set_content_type"
  g_file_info_set_content_type :: ((Ptr FileInfo) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "g_file_info_set_modification_time"
  g_file_info_set_modification_time :: ((Ptr FileInfo) -> ((Ptr ()) -> (IO ())))

foreign import ccall safe "g_file_info_set_size"
  g_file_info_set_size :: ((Ptr FileInfo) -> (CLLong -> (IO ())))

foreign import ccall safe "g_file_info_set_sort_order"
  g_file_info_set_sort_order :: ((Ptr FileInfo) -> (CInt -> (IO ())))