Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
System.FS.Sim.FsTree
Description
Internal part of the mock file system
Intended for qualified import
import System.FS.Sim.FsTree (FsTree) import qualified System.FS.Sim.FsTree as FS
Synopsis
- data FsTree a
- data FsTreeError
- = FsExpectedDir FsPath (NonEmpty Text)
- | FsExpectedFile FsPath
- | FsMissing FsPath (NonEmpty Text)
- | FsExists FsPath
- example :: Monoid a => FsTree a
- empty :: FsTree a
- getDir :: FsPath -> FsTree a -> Either FsTreeError (Folder a)
- getFile :: FsPath -> FsTree a -> Either FsTreeError a
- index :: FsPath -> FsTree a -> Either FsTreeError (FsTree a)
- createDirIfMissing :: FsPath -> FsTree a -> Either FsTreeError (FsTree a)
- createDirWithParents :: FsPath -> FsTree a -> Either FsTreeError (FsTree a)
- openFile :: Monoid a => FsPath -> AllowExisting -> FsTree a -> Either FsTreeError (FsTree a)
- removeDirRecursive :: FsPath -> FsTree a -> Either FsTreeError (FsTree a)
- removeFile :: FsPath -> FsTree a -> Either FsTreeError (FsTree a)
- renameFile :: FsPath -> FsPath -> FsTree a -> Either FsTreeError (FsTree a)
- replace :: FsPath -> a -> FsTree a -> Either FsTreeError (FsTree a)
- find :: forall a. FsPath -> FsTree a -> Either FsTreeError [FsPath]
- pretty :: forall a. (a -> String) -> FsTree a -> String
FsTree type and indexing functions
Simple in-memory representation of a file system
data FsTreeError Source #
File access error
Constructors
FsExpectedDir FsPath (NonEmpty Text) | A path We record both the full path and the invalid suffix. |
FsExpectedFile FsPath | A path No suffix is specified (it must be the last part of the file) |
FsMissing FsPath (NonEmpty Text) | A path We record both the full path and the missing suffix. |
FsExists FsPath | A file was opened with the O_EXCL flag, but it already existed. |
Instances
Show FsTreeError Source # | |
Defined in System.FS.Sim.FsTree Methods showsPrec :: Int -> FsTreeError -> ShowS # show :: FsTreeError -> String # showList :: [FsTreeError] -> ShowS # |
Construction
Indexing
index :: FsPath -> FsTree a -> Either FsTreeError (FsTree a) Source #
Index the FsTree by the given FsPath.
File system operations
createDirIfMissing :: FsPath -> FsTree a -> Either FsTreeError (FsTree a) Source #
Create a directory if it does not already exist
createDirWithParents :: FsPath -> FsTree a -> Either FsTreeError (FsTree a) Source #
Create a directory and its parents if they do not already exist
openFile :: Monoid a => FsPath -> AllowExisting -> FsTree a -> Either FsTreeError (FsTree a) Source #
Open a file: create it if necessary or throw an error if it existed
already wile we were supposed to create it from scratch (when passed
MustBeNew
).
removeDirRecursive :: FsPath -> FsTree a -> Either FsTreeError (FsTree a) Source #
Remove a directory (which must exist) and its contents
removeFile :: FsPath -> FsTree a -> Either FsTreeError (FsTree a) Source #
Remove a file (which must exist)
renameFile :: FsPath -> FsPath -> FsTree a -> Either FsTreeError (FsTree a) Source #
Rename the file (which must exist) from the first path to the second path. If there is already a file at the latter path, it is replaced by the new one.
replace :: FsPath -> a -> FsTree a -> Either FsTreeError (FsTree a) Source #
Replace the contents of the specified file (which must exist)