Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Interface for the default trash directory
Synopsis
- createTrash :: (HasCallStack, HasTrashHome env, MonadLoggerNS m, MonadPathWriter m, MonadReader env m) => m (PathI TrashDirFiles, PathI TrashDirInfo)
- createTrashDir :: (HasCallStack, MonadLoggerNS m, MonadPathWriter m) => PathI TrashHome -> m (PathI TrashDirFiles, PathI TrashDirInfo)
- doesTrashExist :: (HasCallStack, HasTrashHome env, MonadLoggerNS m, MonadPathReader m, MonadReader env m, MonadThrow m) => m Bool
- doesTrashExistPath :: (HasCallStack, MonadLoggerNS m, MonadPathReader m, MonadThrow m) => PathI TrashHome -> m Bool
- mvOriginalToTrash :: (HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), LabelOptic' "originalPath" k pd (PathI TrashEntryOriginalPath), MonadCatch m, MonadFileWriter m, MonadLoggerNS m, MonadPathWriter m, Serial pd, Show pd) => BackendArgs m pd -> PathI TrashHome -> Timestamp -> PathI TrashEntryOriginalPath -> m (pd, PathTypeW, PathI TrashEntryPath)
- mvOriginalToTrash_ :: (HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), LabelOptic' "originalPath" k pd (PathI TrashEntryOriginalPath), MonadCatch m, MonadFileWriter m, MonadLoggerNS m, MonadPathWriter m, Serial pd, Show pd) => BackendArgs m pd -> PathI TrashHome -> Timestamp -> PathI TrashEntryOriginalPath -> m ()
- restoreTrashToOriginal :: (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadCatch m, MonadFileReader m, MonadIORef m, MonadLoggerNS m, MonadPathReader m, MonadPathWriter m, MonadTerminal m, Serial pd, Show pd) => BackendArgs m pd -> (PathData -> m ()) -> PathI TrashHome -> PathI TrashEntryFileName -> m (Maybe SomeException)
- permDeleteFromTrash :: forall m pd k. (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadAsync m, MonadCatch m, MonadFileReader m, MonadHandleWriter m, MonadIORef m, MonadLoggerNS m, MonadPathReader m, MonadPathWriter m, MonadTerminal m, Serial pd, Show pd) => BackendArgs m pd -> (PathData -> m ()) -> Bool -> PathI TrashHome -> PathI TrashEntryFileName -> m (Maybe SomeException)
- mergeTrashDirs :: (HasCallStack, MonadFileReader m, MonadIORef m, MonadLoggerNS m, MonadMask m, MonadPathReader m, MonadPathWriter m) => PathI TrashHome -> PathI TrashHome -> m ()
- data PathDataSearchResult
- findPathData :: (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadCatch m, MonadFileReader m, MonadLoggerNS m, MonadPathReader m, Serial pd, Show pd) => BackendArgs m pd -> PathI TrashHome -> PathI TrashEntryFileName -> m PathDataSearchResult
- getTrashPath :: PathI TrashHome -> PathI TrashEntryFileName -> PathI TrashEntryPath
Trash directory
createTrash :: (HasCallStack, HasTrashHome env, MonadLoggerNS m, MonadPathWriter m, MonadReader env m) => m (PathI TrashDirFiles, PathI TrashDirInfo) Source #
Creates the trash directory if it does not exist.
createTrashDir :: (HasCallStack, MonadLoggerNS m, MonadPathWriter m) => PathI TrashHome -> m (PathI TrashDirFiles, PathI TrashDirInfo) Source #
Creates the trash directory if it does not exist.
doesTrashExist :: (HasCallStack, HasTrashHome env, MonadLoggerNS m, MonadPathReader m, MonadReader env m, MonadThrow m) => m Bool Source #
Returns False
if <trash-home>
does not exist. If <trash-home>
does exist but is "badly-formed" i.e. one of
- <trash-home>/files
- <trash-home>/info
does not, throws TrashDirFilesNotFoundE
or TrashDirInfoNotFoundE
.
If all three dirs exist, returns True
.
doesTrashExistPath :: (HasCallStack, MonadLoggerNS m, MonadPathReader m, MonadThrow m) => PathI TrashHome -> m Bool Source #
Returns False
if <trash-home>
does not exist. If <trash-home>
does exist but is "badly-formed" i.e. one of
- <trash-home>/files
- <trash-home>/info
does not, throws TrashDirFilesNotFoundE
or TrashDirInfoNotFoundE
.
If all three dirs exist, returns True
.
Main actions
mvOriginalToTrash :: (HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), LabelOptic' "originalPath" k pd (PathI TrashEntryOriginalPath), MonadCatch m, MonadFileWriter m, MonadLoggerNS m, MonadPathWriter m, Serial pd, Show pd) => BackendArgs m pd -> PathI TrashHome -> Timestamp -> PathI TrashEntryOriginalPath -> m (pd, PathTypeW, PathI TrashEntryPath) Source #
Moves the PathData
's originalPath
to the trash. Returns the
created pd.
mvOriginalToTrash_ :: (HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), LabelOptic' "originalPath" k pd (PathI TrashEntryOriginalPath), MonadCatch m, MonadFileWriter m, MonadLoggerNS m, MonadPathWriter m, Serial pd, Show pd) => BackendArgs m pd -> PathI TrashHome -> Timestamp -> PathI TrashEntryOriginalPath -> m () Source #
Moves the PathData
's originalPath
to the trash.
restoreTrashToOriginal :: (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadCatch m, MonadFileReader m, MonadIORef m, MonadLoggerNS m, MonadPathReader m, MonadPathWriter m, MonadTerminal m, Serial pd, Show pd) => BackendArgs m pd -> (PathData -> m ()) -> PathI TrashHome -> PathI TrashEntryFileName -> m (Maybe SomeException) Source #
permDeleteFromTrash :: forall m pd k. (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadAsync m, MonadCatch m, MonadFileReader m, MonadHandleWriter m, MonadIORef m, MonadLoggerNS m, MonadPathReader m, MonadPathWriter m, MonadTerminal m, Serial pd, Show pd) => BackendArgs m pd -> (PathData -> m ()) -> Bool -> PathI TrashHome -> PathI TrashEntryFileName -> m (Maybe SomeException) Source #
Permanently deletes the trash path. Returns True
if any deletes fail.
In this case, the error has already been reported, so this is purely for
signaling (i.e. should we exit with an error).
Transformations
:: (HasCallStack, MonadFileReader m, MonadIORef m, MonadLoggerNS m, MonadMask m, MonadPathReader m, MonadPathWriter m) | |
=> PathI TrashHome | src |
-> PathI TrashHome | dest |
-> m () |
Merges source into dest, failing if there are any collisions.
Utils
data PathDataSearchResult Source #
The result of searching for a trash entry.
SearchSuccess (NESeq PathData) | |
SearchSingleFailure (PathI TrashEntryFileName) | |
SearchWildcardFailure (PathI TrashEntryFileName) |
Instances
Show PathDataSearchResult Source # | |
Defined in Charon.Backend.Default.Trash showsPrec :: Int -> PathDataSearchResult -> ShowS # show :: PathDataSearchResult -> String # showList :: [PathDataSearchResult] -> ShowS # | |
Eq PathDataSearchResult Source # | |
Defined in Charon.Backend.Default.Trash (==) :: PathDataSearchResult -> PathDataSearchResult -> Bool # (/=) :: PathDataSearchResult -> PathDataSearchResult -> Bool # |
findPathData :: (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadCatch m, MonadFileReader m, MonadLoggerNS m, MonadPathReader m, Serial pd, Show pd) => BackendArgs m pd -> PathI TrashHome -> PathI TrashEntryFileName -> m PathDataSearchResult Source #
Searches for the given trash name in the trash.