hashed-storage-0.6: Hashed file storage support code.Source codeContentsIndex
Storage.Hashed.Darcs
Description
A few darcs-specific utility functions. These are used for reading and writing darcs and darcs-compatible hashed trees.
Synopsis
type GetHash = (Maybe Int, Hash) -> IO ByteString
darcsDecodeWhite :: String -> FilePath
darcsEncodeWhite :: FilePath -> String
darcsEncodeWhiteBS :: ByteString -> ByteString
decodeDarcsHash :: ByteString -> Hash
decodeDarcsSize :: ByteString -> Maybe Int
darcsGetLocal :: FilePath -> GetHash
darcsLocation :: FilePath -> (Maybe Int, Hash) -> Maybe FilePath
darcsFormatDir :: Tree m -> Maybe ByteString
darcsParseDir :: ByteString -> [(ItemType, Name, Maybe Int, Hash)]
darcsTreeHash :: Tree m -> Hash
darcsUpdateDirHashes :: Tree m -> Tree m
darcsUpdateHashes :: (Monad m, Functor m) => Tree m -> m (Tree m)
darcsAddMissingHashes :: (Monad m, Functor m) => Tree m -> m (Tree m)
readDarcsHashedDir :: GetHash -> (Maybe Int, Hash) -> IO [(ItemType, Name, Maybe Int, Hash)]
readDarcsHashed' :: Bool -> GetHash -> (Maybe Int, Hash) -> IO (Tree IO)
writeDarcsHashed :: Tree IO -> FilePath -> IO Hash
fsCreateHashedFile :: FilePath -> ByteString -> TreeIO ()
hashedTreeIO :: TreeIO a -> Tree IO -> FilePath -> IO (a, Tree IO)
Documentation
type GetHash = (Maybe Int, Hash) -> IO ByteStringSource
darcsDecodeWhite :: String -> FilePathSource

darcsDecodeWhite interprets the Darcs-specific "encoded" filenames produced by darcsEncodeWhite

 darcsDecodeWhite "hello\32\there" == "hello there"
 darcsDecodeWhite "hello\92\there" == "hello\there"
 darcsDecodeWhite "hello\there"    == error "malformed filename"
darcsEncodeWhite :: FilePath -> StringSource

darcsEncodeWhite translates whitespace in filenames to a darcs-specific format (backslash followed by numerical representation according to ord). Note that backslashes are also escaped since they are used in the encoding.

 darcsEncodeWhite "hello there" == "hello\32\there"
 darcsEncodeWhite "hello\there" == "hello\92\there"
darcsEncodeWhiteBS :: ByteString -> ByteStringSource
decodeDarcsHash :: ByteString -> HashSource
decodeDarcsSize :: ByteString -> Maybe IntSource
darcsGetLocal :: FilePath -> GetHashSource
darcsLocation :: FilePath -> (Maybe Int, Hash) -> Maybe FilePathSource
darcsFormatDir :: Tree m -> Maybe ByteStringSource
darcsParseDir :: ByteString -> [(ItemType, Name, Maybe Int, Hash)]Source
darcsTreeHash :: Tree m -> HashSource
Compute a darcs-compatible hash value for a tree-like structure.
darcsUpdateDirHashes :: Tree m -> Tree mSource
darcsUpdateHashes :: (Monad m, Functor m) => Tree m -> m (Tree m)Source
darcsAddMissingHashes :: (Monad m, Functor m) => Tree m -> m (Tree m)Source
readDarcsHashedDir :: GetHash -> (Maybe Int, Hash) -> IO [(ItemType, Name, Maybe Int, Hash)]Source
Read and parse a darcs-style hashed directory listing from a given dir and with a given hash.
readDarcsHashed' :: Bool -> GetHash -> (Maybe Int, Hash) -> IO (Tree IO)Source
Read in a darcs-style hashed tree. This is mainly useful for reading "pristine.hashed". You need to provide the root hash you are interested in (found in _darcs/hashed_inventory).
writeDarcsHashed :: Tree IO -> FilePath -> IO HashSource
Write a Tree into a darcs-style hashed directory.
fsCreateHashedFile :: FilePath -> ByteString -> TreeIO ()Source
Create a hashed file from a FilePath and content. In case the file exists it is kept untouched and is assumed to have the right content. XXX Corrupt files should be probably renamed out of the way automatically or something (probably when they are being read though).
hashedTreeIOSource
::
=> TreeIO ainitial
-> Tree IOdirectory
-> FilePath
-> IO (a, Tree IO)
Run a TreeIO action in a hashed setting. The initial tree is assumed to be fully available from the directory, and any changes will be written out to same. Please note that actual filesystem files are never removed.
Produced by Haddock version 2.6.0