pfile-0.1.0.1: CLI program for profiles management.
Copyright(c) 2024 Illia Shkroba
LicenseBSD3
MaintainerIllia Shkroba <is@pjwstk.edu.pl>
Stabilityunstable
Portabilitynon-portable (Non-Unix systems are not supported)
Safe HaskellSafe-Inferred
LanguageHaskell2010

PFile.Mount

Description

Types and functions for mounting filesystem's objects under some "root" directory.

Synopsis

Documentation

mount :: (MonadError MountError m, MonadIO m) => Strategy -> Root -> Absolute -> m Mount Source #

Mount a Absolute inside of a Root with a chosen Strategy for links. mount does the following:

  1. Moves (renames) Absolute into mountPath under Root. If the move fails due to cross-device move attempt, the Absolute is copied instead.
  2. Removes Absolute at its original location.
  3. Handles links with handle.

Since: 0.1.0.0

mountPath :: Root -> Absolute -> Mount Source #

Mount path of a Absolute inside of a Root. mountPath uses dropDrive on the Absolute and then appends the result to the Root. For example:

>>> mountPath (Root $ Path.Absolute "/a/b/c/") (Path.Absolute "/d/e/f.txt") == Mount (Path.Absolute "/a/b/c/d/e/f.txt")
True

Since: 0.1.0.0

data MountError Source #

Error thrown by mount.

Since: 0.1.0.0

Constructors

OriginMissingError !Absolute !IOException

Absolute is missing. IOException is captured from pathIsSymbolicLink.

LinkHandlingMountError !Error

Error was encountered during handle.

OriginLinkRemoveError !RemoveError

Unable to remove Absolute. This error is thrown after the Absolute got copied under Root.

OriginMoveError !MoveError

Error was encountered during move.

unmount :: (MonadError UnmountError m, MonadIO m) => Root -> Mount -> m Absolute Source #

Unmount a Mount from a Root back to its original location. unmount does the following:

  1. Moves (renames) Mount into originPath from the Root. If the move fails due to cross-device move attempt, the Mount is copied instead.
  2. Removes Mount at its original location.
  3. Handles links with 'PFile.Profile.LinkHandling.handle PFile.Profile.LinkHandling.CopyLink'.

Since: 0.1.0.0

originPath :: MonadError OriginResolveError m => Root -> Mount -> m Absolute Source #

Origin path of a Mount outside of a Root. originPath is an inverse of mountPath. Here is an example usage:

>>> r = originPath (Root $ Path.Absolute "/a/b/c/") (Mount $ Path.Absolute "/a/b/c/d/e/f.txt") & runExcept
>>> r & either (const False) (== Path.Absolute "/d/e/f.txt")
True

originPath works only for Posix paths. Windows paths are not supported currently.

Since: 0.1.0.0

data UnmountError Source #

Error thrown by unmount.

Since: 0.1.0.0

Constructors

OriginResolveError !OriginResolveError

Error was encountered during originPath.

MountMissingError !Absolute !IOException

Mount is missing. IOException is captured from pathIsSymbolicLink.

LinkHandlingUnmountError !Error

Error was encountered during handle.

MountLinkRemoveError !RemoveError

Unable to remove Mount. This error is thrown after the Mount got copied back to its original location.

MountMoveError !MoveError

Error was encountered during move.

data OriginResolveError Source #

Error thrown by originPath.

Since: 0.1.0.0

Constructors

OriginOutsideOfRootError !Mount !Root

Mount is outside of the Root.

newtype Root Source #

Root for mounted Absolutes.

Since: 0.1.0.0

Constructors

Root Absolute 

newtype Mount Source #

mounted Absolute.

Since: 0.1.0.0

Constructors

Mount 

Fields

Instances

Instances details
FromJSON Mount Source # 
Instance details

Defined in PFile.Mount

ToJSON Mount Source # 
Instance details

Defined in PFile.Mount

Eq Mount Source # 
Instance details

Defined in PFile.Mount

Methods

(==) :: Mount -> Mount -> Bool #

(/=) :: Mount -> Mount -> Bool #