libarchive-3.0.2.2: src/Codec/Archive/Types.cpphs
module Codec.Archive.Types ( -- * Concrete (Haskell) data types
Entry (..)
, EntryContent (..)
, Ownership (..)
, ModTime
, Id
, Permissions
, ArchiveEncryption (..)
, ArchiveResult (..)
, ArchiveEntryDigest (..)
-- * Foreign types
, module Codec.Archive.Types.Foreign
-- * Callbacks
, ArchiveOpenCallback
, ArchiveCloseCallback
, ArchiveSwitchCallback
, ArchiveFreeCallback
-- * Marshalling functions
, resultToErr
) where
import Codec.Archive.Types.Foreign
import Data.Int (Int64)
import Foreign.C.Types (CInt, CLong, CTime, CUShort)
import Foreign.Ptr (Ptr)
import System.Posix.Types (CMode (..))
type ArchiveOpenCallback a = Ptr Archive -> Ptr a -> IO ArchiveResult
type ArchiveCloseCallback a = Ptr Archive -> Ptr a -> IO ArchiveResult
type ArchiveSwitchCallback a b = Ptr Archive -> Ptr a -> Ptr b -> IO ArchiveResult
type ArchiveFreeCallback a = Ptr Archive -> Ptr a -> IO ArchiveResult
resultToErr :: ArchiveResult -> CInt
resultToErr = fromIntegral . fromEnum
data ArchiveEncryption = HasEncryption
| NoEncryption
| EncryptionUnsupported
| EncryptionUnknown
deriving (Eq)
-- TODO: support everything here: http://hackage.haskell.org/package/tar/docs/Codec-Archive-Tar-Entry.html#t:EntryContent
data EntryContent fp e = NormalFile e
| Directory
| Symlink !fp !Symlink
| Hardlink !fp
deriving (Show, Eq, Ord)
-- | @e@ is the type of entry contents, for instance 'BSL.ByteString'
--
-- @fp@ is the type of file paths, for instance 'FilePath'
data Entry fp e = Entry { filepath :: !fp -- TODO: bytestring? functorial?
, content :: EntryContent fp e
, permissions :: !Permissions
, ownership :: !Ownership
, time :: !(Maybe ModTime)
}
deriving (Show, Eq, Ord)
data Ownership = Ownership { userName :: !(Maybe String)
, groupName :: !(Maybe String)
, ownerId :: !Id
, groupId :: !Id
}
deriving (Eq, Show, Ord)
#ifdef mingw32_HOST_OS
type Permissions = CUShort
#else
type Permissions = CMode
#endif
type ModTime = (CTime, CLong)
-- | A user or group ID
type Id = Int64