hashed-storage-0.3.5: Hashed file storage support code.Source codeContentsIndex
Storage.Hashed
Contents
Obtaining Trees.
Blob access.
Writing trees.
Unsafe functions for the curious explorer.
Synopsis
readPlainTree :: FilePath -> IO Tree
readDarcsHashed :: FilePath -> Hash -> IO Tree
readDarcsPristine :: FilePath -> IO Tree
read :: Blob -> IO ByteString
readSegment :: FileSegment -> IO ByteString
writePlainTree :: Tree -> FilePath -> IO ()
floatPath :: FilePath -> AnchoredPath
printPath :: Tree -> FilePath -> IO ()
Obtaining Trees.
Please note that Trees obtained this way will contain Stub items. These need to be executed (they are IO actions) in order to be accessed. Use expand to do this. However, many operations are perfectly fine to be used on a stubbed Tree (and it is often more efficient to do everything that can be done before expanding a Tree).
readPlainTree :: FilePath -> IO TreeSource
Read in a plain directory hierarchy from a filesystem. NB. The read function on Blobs with such a Tree is susceptible to file content changes. Since we use mmap in read, this will break referential transparency and produce unexpected results. Please always make sure that all parallel access to the underlying filesystem tree never mutates files. Unlink + recreate is fine though (in other words, the sync/write operations below are safe).
readDarcsHashed :: FilePath -> Hash -> IO TreeSource
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).
readDarcsPristine :: FilePath -> IO TreeSource
Read in a darcs pristine tree. Handles the plain and hashed pristine cases. Does not (and will not) handle the no-pristine case, since that requires replaying patches. Cf. readDarcsHashed and readPlainTree that are used to do the actual Tree construction.
Blob access.
read :: Blob -> IO ByteStringSource
Read a Blob into a Lazy ByteString. Might be backed by an mmap, use with care.
readSegment :: FileSegment -> IO ByteStringSource
Read in a FileSegment into a Lazy ByteString. Implemented using mmap.
Writing trees.
writePlainTree :: Tree -> FilePath -> IO ()Source
Write out *full* tree to a plain directory structure. If you instead want to make incremental updates, refer to Monad.plainTreeIO.
Unsafe functions for the curious explorer.
These are more useful for playing within ghci than for real, serious programs. They generally trade safety for conciseness. Please use responsibly. Don't kill innocent kittens.
floatPath :: FilePath -> AnchoredPathSource
Take a relative FilePath and turn it into an AnchoredPath. The operation is unsafe and if you break it, you keep both pieces. More useful for exploratory purposes (ghci) than for serious programming.
printPath :: Tree -> FilePath -> IO ()Source
Take a relative FilePath within a Tree and print the contents of the object there. Useful for exploration, less so for serious programming.
Produced by Haddock version 2.4.2