-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Provides functions to inspect and manipulate virtual hard disk (VHD) files.
--   
--   Provides functions to inspect and manipulate virtual hard disk (VHD)
--   files, according to the VHD specification (version 1.0).
@package vhd
@version 0.2.2

module Data.Vhd.Time

-- | Represent number of seconds since VHD epoch.
newtype VhdDiffTime
VhdDiffTime :: Word32 -> VhdDiffTime

-- | return the current time in vhd epoch time.
getVHDTime :: IO VhdDiffTime
toPosixSeconds :: VhdDiffTime -> POSIXTime
toUTCTime :: VhdDiffTime -> UTCTime
instance GHC.Classes.Ord Data.Vhd.Time.VhdDiffTime
instance GHC.Classes.Eq Data.Vhd.Time.VhdDiffTime
instance GHC.Read.Read Data.Vhd.Time.VhdDiffTime
instance GHC.Show.Show Data.Vhd.Time.VhdDiffTime

module Data.Vhd.Lowlevel

-- | read header directly from a vhd file
readHeader :: FilePath -> IO (Either String Header)

-- | read footer directly from a vhd file.
readFooter :: FilePath -> IO (Either String Footer)

-- | re-write an header in a VHD file
writeHeader :: FilePath -> Header -> IO ()

-- | re-write both footer in a VHD file
writeFooter :: FilePath -> Footer -> IO ()

module Data.Vhd

-- | Creates an empty VHD file with the specified parameters.
create :: FilePath -> CreateParameters -> IO ()
data CreateParameters
CreateParameters :: BlockSize -> DiskType -> Maybe VhdDiffTime -> Maybe ParentUnicodeName -> Maybe UniqueId -> Maybe VhdDiffTime -> Maybe UniqueId -> Bool -> VirtualByteCount -> CreateParameters
[createBlockSize] :: CreateParameters -> BlockSize
[createDiskType] :: CreateParameters -> DiskType
[createParentTimeStamp] :: CreateParameters -> Maybe VhdDiffTime
[createParentUnicodeName] :: CreateParameters -> Maybe ParentUnicodeName
[createParentUniqueId] :: CreateParameters -> Maybe UniqueId
[createTimeStamp] :: CreateParameters -> Maybe VhdDiffTime
[createUuid] :: CreateParameters -> Maybe UniqueId
[createUseBatmap] :: CreateParameters -> Bool
[createVirtualSize] :: CreateParameters -> VirtualByteCount
defaultCreateParameters :: CreateParameters

-- | Retrieves the header and footer from a VHD file.
getInfo :: FilePath -> IO (Either String (Header, Footer))
snapshot :: Vhd -> FilePath -> IO ()

-- | Reads data from the whole virtual address space of the given VHD.
readData :: Vhd -> IO ByteString

-- | Reads data from the given virtual address range of the given VHD.
--   
--   TODO: modify this function to read sub-blocks where appropriate.
readDataRange :: Vhd -> Word64 -> Word64 -> IO ByteString

-- | Writes data to the given virtual address of the given VHD.
writeDataRange :: Vhd -> Word64 -> ByteString -> IO ()
withVhd :: FilePath -> (Vhd -> IO a) -> IO a
class Sized a
sized :: (Sized a, Num n) => a -> n

-- | block size
newtype BlockSize
BlockSize :: Word32 -> BlockSize

-- | The offset from the beginning of a block in bytes
newtype BlockByteAddress
BlockByteAddress :: Word32 -> BlockByteAddress

-- | The offset from the beginning of a block in sectors
newtype BlockSectorAddress
BlockSectorAddress :: Word32 -> BlockSectorAddress

-- | The absolute number of the block
newtype VirtualBlockAddress
VirtualBlockAddress :: Word32 -> VirtualBlockAddress

-- | An absolute address in byte in the vhd content space
newtype VirtualByteAddress
VirtualByteAddress :: Word64 -> VirtualByteAddress
type DiskGeometryCylinders = Word16
type DiskGeometryHeads = Word8
type DiskGeometrySectorsPerTrack = Word8
type PhysicalByteAddress = Word64
type PhysicalByteCount = Word64
type PhysicalSectorAddress = Word32
type PhysicalSectorCount = Word32
type VirtualBlockCount = Word32
type VirtualByteCount = Word64
type VirtualSectorAddress = Word32
type VirtualSectorCount = Word32
vaddrPlus :: VirtualByteAddress -> Word64 -> VirtualByteAddress
vaddrToBlock :: VirtualByteAddress -> BlockSize -> (VirtualBlockAddress, BlockByteAddress, Word32)

-- | increment the virtual address to align to the next block
vaddrNextBlock :: VirtualByteAddress -> BlockSize -> VirtualByteAddress
addrToSector :: Word64 -> PhysicalSectorAddress
data Version
Version :: VersionMajor -> VersionMinor -> Version
type VersionMajor = Word16
type VersionMinor = Word16
data CreatorHostOs
CreatorHostOsUnknown :: CreatorHostOs
CreatorHostOsWindows :: CreatorHostOs
CreatorHostOsMacintosh :: CreatorHostOs
data DiskGeometry
DiskGeometry :: DiskGeometryCylinders -> DiskGeometryHeads -> DiskGeometrySectorsPerTrack -> DiskGeometry
data DiskType
DiskTypeFixed :: DiskType
DiskTypeDynamic :: DiskType
DiskTypeDifferencing :: DiskType
newtype Cookie
Cookie :: ByteString -> Cookie
newtype CreatorApplication
CreatorApplication :: ByteString -> CreatorApplication
data ParentLocatorEntry
ParentLocatorEntry :: Word32 -> Word32 -> Word32 -> Word64 -> ParentLocatorEntry
[locatorCode] :: ParentLocatorEntry -> Word32
[locatorDataSpace] :: ParentLocatorEntry -> Word32
[locatorDataLength] :: ParentLocatorEntry -> Word32
[locatorDataOffset] :: ParentLocatorEntry -> Word64
nullParentLocatorEntry :: ParentLocatorEntry
newtype ParentUnicodeName
ParentUnicodeName :: String -> ParentUnicodeName
newtype ParentLocatorEntries
ParentLocatorEntries :: [ParentLocatorEntry] -> ParentLocatorEntries

-- | smart constructor for Cookie
cookie :: ByteString -> Cookie

-- | smart constructor for CreatorApplication
creatorApplication :: ByteString -> CreatorApplication

-- | smart constructor for ParentLocatorEntries
parentLocatorEntries :: [ParentLocatorEntry] -> ParentLocatorEntries
parentUnicodeName :: [Char] -> ParentUnicodeName
data Header
Header :: Cookie -> PhysicalByteAddress -> PhysicalByteAddress -> Version -> VirtualBlockCount -> BlockSize -> Checksum -> UniqueId -> VhdDiffTime -> ByteString -> ParentUnicodeName -> ParentLocatorEntries -> Header
[headerCookie] :: Header -> Cookie
[headerDataOffset] :: Header -> PhysicalByteAddress
[headerTableOffset] :: Header -> PhysicalByteAddress
[headerVersion] :: Header -> Version
[headerMaxTableEntries] :: Header -> VirtualBlockCount
[headerBlockSize] :: Header -> BlockSize
[headerChecksum] :: Header -> Checksum
[headerParentUniqueId] :: Header -> UniqueId
[headerParentTimeStamp] :: Header -> VhdDiffTime
[headerReserved1] :: Header -> ByteString
[headerParentUnicodeName] :: Header -> ParentUnicodeName
[headerParentLocatorEntries] :: Header -> ParentLocatorEntries
newtype Checksum
Checksum :: Word32 -> Checksum
class Serialize a => CheckSumable a
calculateChecksum :: CheckSumable a => a -> Checksum
getChecksum :: CheckSumable a => a -> Checksum
setChecksum :: CheckSumable a => Checksum -> a -> a
checksumCalculate :: ByteString -> Checksum
verifyChecksum :: CheckSumable a => a -> Bool
adjustChecksum :: CheckSumable a => a -> a
data Footer
Footer :: Cookie -> Bool -> Version -> PhysicalByteAddress -> VhdDiffTime -> CreatorApplication -> Version -> CreatorHostOs -> VirtualByteCount -> VirtualByteCount -> DiskGeometry -> DiskType -> Checksum -> UniqueId -> Bool -> Footer
[footerCookie] :: Footer -> Cookie
[footerIsTemporaryDisk] :: Footer -> Bool
[footerFormatVersion] :: Footer -> Version
[footerDataOffset] :: Footer -> PhysicalByteAddress
[footerTimeStamp] :: Footer -> VhdDiffTime
[footerCreatorApplication] :: Footer -> CreatorApplication
[footerCreatorVersion] :: Footer -> Version
[footerCreatorHostOs] :: Footer -> CreatorHostOs
[footerOriginalSize] :: Footer -> VirtualByteCount
[footerCurrentSize] :: Footer -> VirtualByteCount
[footerDiskGeometry] :: Footer -> DiskGeometry
[footerDiskType] :: Footer -> DiskType
[footerChecksum] :: Footer -> Checksum
[footerUniqueId] :: Footer -> UniqueId
[footerIsSavedState] :: Footer -> Bool
data UniqueId

-- | smart constructor for uniqueId
uniqueId :: ByteString -> UniqueId
randomUniqueId :: IO UniqueId
instance GHC.Classes.Eq Data.Vhd.CreateParameters
instance GHC.Show.Show Data.Vhd.CreateParameters
