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.TrashCan

Description

Types and functions for trashing filesystem's objects.

Synopsis

Documentation

create :: (MonadError CreateError m, MonadIO m) => m TrashCan Source #

Create a new trash can.

Since: 0.1.0.0

data CreateError Source #

Error thrown by create.

Since: 0.1.0.0

Constructors

TemporaryDirectoryResolveError !IOException

IOException was encountered during temporary directory resolving.

TemporaryDirectoryCreateError !Absolute !IOException

IOException was encountered during temporary directory creation.

trash :: (MonadError TrashError m, MonadIO m) => Absolute -> TrashCan -> m () Source #

mount Absolute inside of a TrashCan with CopyLink strategy for links.

Since: 0.1.0.0

data TrashError Source #

Error thrown by trash.

Since: 0.1.0.0

Constructors

AlreadyTrashedError !Absolute !TrashCan

Absolute is already trashed.

MountError !MountError

Error was encountered during mount.

restoreAll :: (MonadWriter [RestoreEntryError] m, MonadIO m) => TrashCan -> m () Source #

restore all trashed filesystem's objects back to their original locations. When an error is encountered during restore, restoreAll terminates and provides successfully restoreed entries via a MonadWriter.

Since: 0.1.0.0

restore :: (MonadError RestoreError m, MonadIO m) => TrashCan -> Absolute -> m () Source #

unmount Absolute (turned into Mount) from a TrashCan back to its original location (before trash).

Since: 0.1.0.0

data RestoreEntryError Source #

Error provided via MonadWriter by restoreAll.

Since: 0.1.0.0

Constructors

RestoreEntryError !Absolute !RestoreError

Error was encountered during restore.

newtype RestoreError Source #

Error thrown by restore.

Since: 0.1.0.0

Constructors

UnmountError UnmountError

Error was encountered during unmount.

remove :: (MonadError RemoveError m, MonadIO m) => TrashCan -> m () Source #

Remove a TrashCan forcibly.

Since: 0.1.0.0

newtype RemoveError Source #

Error thrown by remove.

Since: 0.1.0.0

Constructors

TemporaryDirectoryRemoveError RemoveError

Error was encountered during temporary directory removal.

dumpTrashed :: (MonadError DumpTrashedError m, MonadIO m) => TrashCan -> m Absolute Source #

Dump trashed to a file inside of the root directory.

Since: 0.1.0.0

newtype DumpTrashedError Source #

Error thrown by dumpTrashed.

Since: 0.1.0.0

Constructors

DumpTrashedError WriteFileError

Error was encountered during writing to a "trashed.txt" file inside of the root directory.

trashed :: MonadIO m => TrashCan -> m [Absolute] Source #

List of trashed filesystem's objects.

Since: 0.1.0.0

data TrashCan Source #

Trash can for filesystem's objects.

Since: 0.1.0.0

Constructors

TrashCan !Absolute !Absolute !(IORef [Absolute])