Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Storage.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
- 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 hOpen
ing 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
Eq AllowExisting Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types Methods (==) ∷ AllowExisting → AllowExisting → Bool Source # (/=) ∷ AllowExisting → AllowExisting → Bool Source # | |
Show AllowExisting Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types | |
Condense AllowExisting Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types Methods |
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 |
Defined in GHC.IO.Device Methods succ ∷ SeekMode → SeekMode Source # pred ∷ SeekMode → SeekMode Source # toEnum ∷ Int → SeekMode Source # fromEnum ∷ SeekMode → Int Source # enumFrom ∷ SeekMode → [SeekMode] Source # enumFromThen ∷ SeekMode → SeekMode → [SeekMode] Source # enumFromTo ∷ SeekMode → SeekMode → [SeekMode] Source # enumFromThenTo ∷ SeekMode → SeekMode → SeekMode → [SeekMode] Source # | |
Eq SeekMode | Since: base-4.2.0.0 |
Ord SeekMode | Since: base-4.2.0.0 |
Read SeekMode | Since: base-4.2.0.0 |
Show SeekMode | Since: base-4.2.0.0 |
Ix SeekMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Device | |
Condense SeekMode Source # | |
Paths
newtype MountPoint Source #
Mount point
FsPath
s are not absolute paths, but must be interpreted with respect to
a particualar mount point.
Constructors
MountPoint FilePath |
fsPathFromList ∷ [Text] → FsPath Source #
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 #
opaque
Handles
Constructors
Handle | |
Fields
|
Instances
Eq h ⇒ Eq (Handle h) Source # | |
Show (Handle h) Source # | |
Generic (Handle h) Source # | |
NoThunks (Handle h) Source # | |
Condense (Handle h) Source # | |
type Rep (Handle h) Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types type Rep (Handle h) = D1 ('MetaData "Handle" "Ouroboros.Consensus.Storage.FS.API.Types" "ouroboros-consensus-0.1.0.2-inplace" '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 Ouroboros.Consensus.Storage.FS.API.Types Methods succ ∷ AbsOffset → AbsOffset Source # pred ∷ AbsOffset → AbsOffset Source # toEnum ∷ Int → AbsOffset Source # fromEnum ∷ AbsOffset → Int Source # enumFrom ∷ AbsOffset → [AbsOffset] Source # enumFromThen ∷ AbsOffset → AbsOffset → [AbsOffset] Source # enumFromTo ∷ AbsOffset → AbsOffset → [AbsOffset] Source # enumFromThenTo ∷ AbsOffset → AbsOffset → AbsOffset → [AbsOffset] Source # | |
Eq AbsOffset Source # | |
Num AbsOffset Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types | |
Ord AbsOffset Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types | |
Show AbsOffset Source # | |
Errors
Constructors
FsError | |
Fields
|
Instances
Show FsError Source # | |
Exception FsError Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types Methods toException ∷ FsError → SomeException 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
Eq FsErrorPath Source # | We only care to compare the |
Defined in Ouroboros.Consensus.Storage.FS.API.Types Methods (==) ∷ FsErrorPath → FsErrorPath → Bool Source # (/=) ∷ FsErrorPath → FsErrorPath → Bool Source # | |
Show FsErrorPath Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types | |
Condense FsErrorPath Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types Methods condense ∷ FsErrorPath → String Source # |
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
Eq FsErrorType Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types Methods (==) ∷ FsErrorType → FsErrorType → Bool Source # (/=) ∷ FsErrorType → FsErrorType → Bool Source # | |
Show FsErrorType Source # | |
Defined in Ouroboros.Consensus.Storage.FS.API.Types |
fsToFsErrorPathUnmounted ∷ FsPath → FsErrorPath Source #
Like fsToFsErrorPath
, but when we don't have a MountPoint
hasMountPoint ∷ FsError → Bool Source #
isFsErrorType ∷ FsErrorType → FsError → Bool 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.