| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
System.FS.API.Types
Synopsis
- data AllowExisting
- data OpenMode
- data SeekMode
- allowExisting :: OpenMode -> AllowExisting
- newtype MountPoint = MountPoint FilePath
- fsFromFilePath :: MountPoint -> FilePath -> Maybe FsPath
- fsPathFromList :: [Text] -> FsPath
- fsPathInit :: HasCallStack => FsPath -> FsPath
- fsPathSplit :: FsPath -> Maybe (FsPath, Text)
- fsPathToList :: FsPath -> [Text]
- fsToFilePath :: MountPoint -> FsPath -> FilePath
- mkFsPath :: [String] -> FsPath
- (<.>) :: FsPath -> String -> FsPath
- addExtension :: FsPath -> String -> FsPath
- (</>) :: FsPath -> FsPath -> FsPath
- combine :: FsPath -> FsPath -> FsPath
- data FsPath
- data Handle h = Handle {
- handleRaw :: !h
- handlePath :: !FsPath
- newtype AbsOffset = AbsOffset {}
- data FsError = FsError {}
- data FsErrorPath = FsErrorPath (Maybe MountPoint) FsPath
- data FsErrorType
- fsToFsErrorPath :: MountPoint -> FsPath -> FsErrorPath
- fsToFsErrorPathUnmounted :: FsPath -> FsErrorPath
- hasMountPoint :: FsError -> Bool
- isFsErrorType :: FsErrorType -> FsError -> Bool
- prettyFsError :: FsError -> String
- sameFsError :: FsError -> FsError -> Bool
- ioToFsError :: HasCallStack => FsErrorPath -> IOError -> FsError
- ioToFsErrorType :: IOError -> FsErrorType
Modes
data AllowExisting Source #
When opening a file:
Constructors
| AllowExisting | The file may already exist. If it does, it is reopened. If it doesn't, it is created. |
| MustBeNew | The file may not yet exist. If it does, an error
( |
Instances
| Show AllowExisting Source # | |
Defined in System.FS.API.Types Methods showsPrec :: Int -> AllowExisting -> ShowS # show :: AllowExisting -> String # showList :: [AllowExisting] -> ShowS # | |
| Condense AllowExisting Source # | |
Defined in System.FS.API.Types Methods condense :: AllowExisting -> String Source # | |
| Eq AllowExisting Source # | |
Defined in System.FS.API.Types Methods (==) :: AllowExisting -> AllowExisting -> Bool # (/=) :: AllowExisting -> AllowExisting -> Bool # | |
How to hOpen a new file.
A mode that determines the effect of hSeek hdl mode i.
Constructors
| AbsoluteSeek | the position of |
| RelativeSeek | the position of |
| SeekFromEnd | the position of |
Instances
| Enum SeekMode | Since: base-4.2.0.0 |
| Ix SeekMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Device Methods range :: (SeekMode, SeekMode) -> [SeekMode] # index :: (SeekMode, SeekMode) -> SeekMode -> Int # unsafeIndex :: (SeekMode, SeekMode) -> SeekMode -> Int # inRange :: (SeekMode, SeekMode) -> SeekMode -> Bool # rangeSize :: (SeekMode, SeekMode) -> Int # unsafeRangeSize :: (SeekMode, SeekMode) -> Int # | |
| Read SeekMode | Since: base-4.2.0.0 |
| Show SeekMode | Since: base-4.2.0.0 |
| Condense SeekMode Source # | |
| Eq SeekMode | Since: base-4.2.0.0 |
| Ord SeekMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Device | |
Paths
newtype MountPoint Source #
Mount point
FsPaths are not absolute paths, but must be interpreted with respect to
a particualar mount point.
Constructors
| MountPoint FilePath |
fsFromFilePath :: MountPoint -> FilePath -> Maybe FsPath Source #
fsPathFromList :: [Text] -> FsPath Source #
Create a path from a list of directory/file names. All of the names should be non-empty.
fsPathInit :: HasCallStack => FsPath -> FsPath Source #
Drop the final component of the path
Undefined if the path is empty.
fsPathToList :: FsPath -> [Text] Source #
fsToFilePath :: MountPoint -> FsPath -> FilePath Source #
(<.>) :: FsPath -> String -> FsPath infixr 7 Source #
Add an extension, even if there is already one there.
This works similarly to <.>.
(</>) :: FsPath -> FsPath -> FsPath infixr 5 Source #
Combine two paths with a path separator.
This works similarly to </>, but since the arguments are
relative paths, the corner cases for </> do not apply.
Specifically, the second path will never start with a path separator or a
drive letter, so the result is simply the concatenation of the two paths.
If either operand is empty, the other operand is returned. The result of combining two empty paths is the empty path
opaque
A relative path.
Invariant
The user of this library is tasked with picking sensible names of directories/files on a path. Amongst others, the following should hold:
- Names are non-empty
- Names are monotonic, i.e., they are not equal to
.. - Names should not contain path separators or drive letters
In particular, names that satisfy these invariants should result in an
FsPath that remains relative to the HasFS instance root. For example, an
would try to access the root folder, which is most likely
outside of the scope of the HasFS instance.FsPath ["/"]
".." should not be used because fs-sim will not be able to follow these
types of back-links. fs-sim will interpret ".." as a directory name
instead.
Handles
Constructors
| Handle | |
Fields
| |
Instances
| Generic (Handle h) Source # | |
| Show (Handle h) Source # | |
| NFData h => NFData (Handle h) Source # | |
Defined in System.FS.API.Types | |
| Condense (Handle h) Source # | |
| Eq h => Eq (Handle h) Source # | |
| type Rep (Handle h) Source # | |
Defined in System.FS.API.Types type Rep (Handle h) = D1 ('MetaData "Handle" "System.FS.API.Types" "fs-api-0.3.0.0-9Af060UItM4vLHAUAXnQ0" 'False) (C1 ('MetaCons "Handle" 'PrefixI 'True) (S1 ('MetaSel ('Just "handleRaw") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 h) :*: S1 ('MetaSel ('Just "handlePath") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FsPath))) | |
Offset
Constructors
| AbsOffset | |
Fields | |
Instances
| Bounded AbsOffset Source # | |
| Enum AbsOffset Source # | |
Defined in System.FS.API.Types Methods succ :: AbsOffset -> AbsOffset # pred :: AbsOffset -> AbsOffset # fromEnum :: AbsOffset -> Int # enumFrom :: AbsOffset -> [AbsOffset] # enumFromThen :: AbsOffset -> AbsOffset -> [AbsOffset] # enumFromTo :: AbsOffset -> AbsOffset -> [AbsOffset] # enumFromThenTo :: AbsOffset -> AbsOffset -> AbsOffset -> [AbsOffset] # | |
| Num AbsOffset Source # | |
Defined in System.FS.API.Types | |
| Show AbsOffset Source # | |
| Eq AbsOffset Source # | |
| Ord AbsOffset Source # | |
Errors
Constructors
| FsError | |
Fields
| |
Instances
| Exception FsError Source # | |
Defined in System.FS.API.Types Methods toException :: FsError -> SomeException # fromException :: SomeException -> Maybe FsError # displayException :: FsError -> String # | |
| Show FsError Source # | |
data FsErrorPath Source #
For better error reporting to the end user, we want to include the mount point of the file. But the mountpoint may not always be available, like when we mock the fs or we simulate fs errors.
Constructors
| FsErrorPath (Maybe MountPoint) FsPath |
Instances
| Show FsErrorPath Source # | |
Defined in System.FS.API.Types Methods showsPrec :: Int -> FsErrorPath -> ShowS # show :: FsErrorPath -> String # showList :: [FsErrorPath] -> ShowS # | |
| Condense FsErrorPath Source # | |
Defined in System.FS.API.Types Methods condense :: FsErrorPath -> String Source # | |
| Eq FsErrorPath Source # | We only care to compare the |
Defined in System.FS.API.Types | |
data FsErrorType Source #
Constructors
| FsIllegalOperation | |
| FsResourceInappropriateType | e.g the user tried to open a directory with hOpen rather than a file. |
| FsResourceAlreadyInUse | |
| FsResourceDoesNotExist | |
| FsResourceAlreadyExist | |
| FsReachedEOF | |
| FsDeviceFull | |
| FsTooManyOpenFiles | |
| FsInsufficientPermissions | |
| FsInvalidArgument | |
| FsOther | Used for all other error types |
Instances
| Show FsErrorType Source # | |
Defined in System.FS.API.Types Methods showsPrec :: Int -> FsErrorType -> ShowS # show :: FsErrorType -> String # showList :: [FsErrorType] -> ShowS # | |
| Eq FsErrorType Source # | |
Defined in System.FS.API.Types | |
fsToFsErrorPath :: MountPoint -> FsPath -> FsErrorPath Source #
fsToFsErrorPathUnmounted :: FsPath -> FsErrorPath Source #
Like fsToFsErrorPath, but when we don't have a MountPoint
hasMountPoint :: FsError -> Bool Source #
isFsErrorType :: FsErrorType -> FsError -> Bool Source #
prettyFsError :: FsError -> String Source #
sameFsError :: FsError -> FsError -> Bool Source #
Check if two errors are semantically the same error
This ignores the error string, the errno, and the callstack.
From IOError to FsError
ioToFsError :: HasCallStack => FsErrorPath -> IOError -> FsError Source #
ioToFsErrorType :: IOError -> FsErrorType Source #
Assign an FsErrorType to the given IOError.
Note that we don't always use the classification made by
errnoToIOError (also see Error) because it
combines some errors into one IOErrorType, e.g., EMFILE (too many open
files) and ENOSPC (no space left on device) both result in
ResourceExhausted while we want to keep them separate. For this reason,
we do a classification of our own based on the errno while sometimes
deferring to the existing classification.
See the ERRNO(3) man page for the meaning of the different errnos.