Copyright | (c) 2018 Drew Hess |
---|---|
License | BSD3 |
Maintainer | Drew Hess <src@drewhess.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Types and functions to emulate a (pure) rudimentary Posix-style filesystem.
This module was written for internal use only. Its interface may change at any time. Documentation in this module is sparse, by design.
N.B.: This mock filesystem implementation was written with the
intention of doing only just enough to emulate the operations needed
by the MonadSysfs
type class. Though
it may be possible to use this implementation for other purposes, it
has neither been designed nor tested for that. Use at your own risk
and please do not submit requests for addtional functionality.
Synopsis
- type Name = FilePath
- data File = File {}
- data FileType
- data DirNode = DirNode {
- _dirNodeName :: !Name
- _files :: [File]
- type Directory = Tree DirNode
- directory :: Name -> [File] -> [Directory] -> Directory
- dirName :: Directory -> Name
- files :: Directory -> [File]
- dirNode :: Directory -> DirNode
- subdirs :: Directory -> [Directory]
- data MockFSCrumb = MockFSCrumb {}
- data MockFSZipper = MockFSZipper {
- _cwd :: Directory
- _crumbs :: [MockFSCrumb]
- cd :: FilePath -> MockFSZipper -> Either IOError MockFSZipper
- pathFromRoot :: MockFSZipper -> FilePath
- findFile :: Name -> Directory -> Maybe FileType
- mkdir :: Name -> MockFSZipper -> Either IOError MockFSZipper
- mkfile :: Name -> FileType -> Bool -> MockFSZipper -> Either IOError MockFSZipper
- rmdir :: Name -> MockFSZipper -> Either IOError MockFSZipper
- rmfile :: Name -> MockFSZipper -> Either IOError MockFSZipper
Mock filesystem types
data MockFSCrumb Source #
Instances
Eq MockFSCrumb Source # | |
Defined in System.GPIO.Linux.Sysfs.Mock.Internal (==) :: MockFSCrumb -> MockFSCrumb -> Bool # (/=) :: MockFSCrumb -> MockFSCrumb -> Bool # | |
Show MockFSCrumb Source # | |
Defined in System.GPIO.Linux.Sysfs.Mock.Internal showsPrec :: Int -> MockFSCrumb -> ShowS # show :: MockFSCrumb -> String # showList :: [MockFSCrumb] -> ShowS # |
data MockFSZipper Source #
An opaque type representing the current state of the mock sysfs
filesystem. Because the constructor is not exported via the public
interface, you cannot create these directly, but you can manipulate
them using the exposed mock sysfs
operations and then pass those
MockFSZipper
s around.
MockFSZipper | |
|
Instances
Eq MockFSZipper Source # | |
Defined in System.GPIO.Linux.Sysfs.Mock.Internal (==) :: MockFSZipper -> MockFSZipper -> Bool # (/=) :: MockFSZipper -> MockFSZipper -> Bool # | |
Show MockFSZipper Source # | |
Defined in System.GPIO.Linux.Sysfs.Mock.Internal showsPrec :: Int -> MockFSZipper -> ShowS # show :: MockFSZipper -> String # showList :: [MockFSZipper] -> ShowS # |
Mock filesystem operations
cd :: FilePath -> MockFSZipper -> Either IOError MockFSZipper Source #
pathFromRoot :: MockFSZipper -> FilePath Source #
mkdir :: Name -> MockFSZipper -> Either IOError MockFSZipper Source #
mkfile :: Name -> FileType -> Bool -> MockFSZipper -> Either IOError MockFSZipper Source #
rmdir :: Name -> MockFSZipper -> Either IOError MockFSZipper Source #
rmfile :: Name -> MockFSZipper -> Either IOError MockFSZipper Source #