HsSVN-0.4.3.1: Partial Subversion (SVN) binding for HaskellContentsIndex
Subversion.FileSystem.Root
Contents
Class
Getting file content and others
Getting node type
Getting node property
Getting nodes in directory
Getting change list
Description
An interface to functions that work on both existing revisions and ongoing transactions in a filesystem.
Synopsis
class Monad m => MonadFS m where
getRoot :: m FileSystemRoot
unsafeIOToFS :: IO a -> m a
isTransaction :: m Bool
getFileLength :: MonadFS m => FilePath -> m Integer
getFileMD5 :: MonadFS m => FilePath -> m [Word8]
getFileContents :: MonadFS m => FilePath -> m String
getFileContentsLBS :: MonadFS m => FilePath -> m ByteString
checkPath :: MonadFS m => FilePath -> m NodeKind
isDirectory :: MonadFS m => FilePath -> m Bool
isFile :: MonadFS m => FilePath -> m Bool
getNodeProp :: MonadFS m => FilePath -> String -> m (Maybe String)
getNodePropList :: MonadFS m => FilePath -> m [(String, String)]
getDirEntries :: MonadFS m => FilePath -> m [DirEntry]
getPathsChanged :: MonadFS m => m [(FilePath, PathChange)]
Class
class Monad m => MonadFS m where
MonadFS m is a monad which holds internally either an existing revision or ongoing transaction.
Methods
getRoot :: m FileSystemRoot
unsafeIOToFS :: IO a -> m a

unsafeIOToFS runs an IO monad in MonadFS.

This is unsafe if the monad is a transaction monad. When a transaction fails before getting commited, all transactional operations are cancelled at once. But if you had launched missiles with unsafeIOToFS during the transaction, your missiles can never go back. So you must use this carefully.

isTransaction :: m Bool
isTransaction returns True iff the monad is a transaction monad.
show/hide Instances
Getting file content and others
getFileLength :: MonadFS m => FilePath -> m Integer
getFileLength path returns the length of file path.
getFileMD5 :: MonadFS m => FilePath -> m [Word8]
getFileMD5 path returns the MD5 checksum of file path. If the filesystem does not have a prerecorded checksum for path, it doesn't calculate a checksum dynamically, just puts all 0's into the resulting digest. (By convention, the all-zero checksum is considered to match any checksum.)
getFileContents :: MonadFS m => FilePath -> m String

getFileContents path returns the content of file path.

If this is a non-transactional monad (that is, a monad whose isTransaction returns False), it reads the content lazilly. But if this is a transactional monad, getFileContents does the operation strictly: I mean it loads the entire file onto the memory! This is because svn_fs_file_contents() in the libsvn_fs doesn't guarantee, when we are in a transaction, that we can progressively read a file which was suddenly modified in the same transaction during the progressive reading.

I think getFileContents might have to return [Word8] instead of String because every files in a filesystem should be considered binary. Yes, readFile also returns String but this is an immature part of Haskell. I wish someday Haskell gets more clear distinction between binary data and an Unicode string, then I change the form of getFileContents alike.

getFileContentsLBS :: MonadFS m => FilePath -> m ByteString
getFileContentsLBS does the same thing as getFileContents but returns Data.ByteString.Lazy.ByteString instead.
Getting node type
checkPath :: MonadFS m => FilePath -> m NodeKind
checkPath path returns a NodeKind for path. Unlike most other actions, checkPath doesn't throw an error even if the path doesn't point to an existent node: in that case it just returns NoNode.
isDirectory :: MonadFS m => FilePath -> m Bool
isDirectory path returns True iff the path points to a directory in a revision or transaction. It returns False for nonexistent paths.
isFile :: MonadFS m => FilePath -> m Bool
isFile path returns True iff the path points to a file in a revision or transaction. It returns False for nonexistent paths.
Getting node property
getNodeProp :: MonadFS m => FilePath -> String -> m (Maybe String)
getNodeProp path propName returns the value of the property named propName of path in a revision or transaction.
getNodePropList :: MonadFS m => FilePath -> m [(String, String)]
getNodePropList path returns the property list of path in a revision or transaction.
Getting nodes in directory
getDirEntries :: MonadFS m => FilePath -> m [DirEntry]
getDirEntries path returns a list containing the entries of the directory at path in a revision or transaction.
Getting change list
getPathsChanged :: MonadFS m => m [(FilePath, PathChange)]
getPathsChanged returns a list containing descriptions of the paths changed under a revision or transaction.
Produced by Haddock version 2.6.0