fs-sim-0.3.1.0: Simulated file systems
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

FsTree type and indexing functions

data FsTree a Source #

Simple in-memory representation of a file system

Constructors

File !a 
Folder !(Folder a) 

Instances

Instances details
Functor FsTree Source # 
Instance details

Defined in System.FS.Sim.FsTree

Methods

fmap :: (a -> b) -> FsTree a -> FsTree b #

(<$) :: a -> FsTree b -> FsTree a #

Generic (FsTree a) Source # 
Instance details

Defined in System.FS.Sim.FsTree

Associated Types

type Rep (FsTree a) :: Type -> Type #

Methods

from :: FsTree a -> Rep (FsTree a) x #

to :: Rep (FsTree a) x -> FsTree a #

Show a => Show (FsTree a) Source # 
Instance details

Defined in System.FS.Sim.FsTree

Methods

showsPrec :: Int -> FsTree a -> ShowS #

show :: FsTree a -> String #

showList :: [FsTree a] -> ShowS #

Eq a => Eq (FsTree a) Source # 
Instance details

Defined in System.FS.Sim.FsTree

Methods

(==) :: FsTree a -> FsTree a -> Bool #

(/=) :: FsTree a -> FsTree a -> Bool #

type Rep (FsTree a) Source # 
Instance details

Defined in System.FS.Sim.FsTree

type Rep (FsTree a)

data FsTreeError Source #

File access error

Constructors

FsExpectedDir FsPath (NonEmpty Text)

A path ..a.. where a is a file rather than a dir

We record both the full path and the invalid suffix.

FsExpectedFile FsPath

A path ..a.. where a is a dir rather than a file

No suffix is specified (it must be the last part of the file)

FsMissing FsPath (NonEmpty Text)

A path ..a.. or ../a where directory or file a is missing

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

Instances details
Show FsTreeError Source # 
Instance details

Defined in System.FS.Sim.FsTree

example :: Monoid a => FsTree a Source #

Example

Construction

Indexing

getDir :: FsPath -> FsTree a -> Either FsTreeError (Folder a) Source #

getFile :: FsPath -> FsTree a -> Either FsTreeError a Source #

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)

Path-listing

find :: forall a. FsPath -> FsTree a -> Either FsTreeError [FsPath] Source #

Pretty-printing

pretty :: forall a. (a -> String) -> FsTree a -> String Source #