path-io 1.6.3 → 1.7.0
raw patch · 4 files changed
+103/−10 lines, 4 files
Files
- CHANGELOG.md +5/−0
- Path/IO.hs +84/−0
- path-io.cabal +9/−9
- tests/Main.hs +5/−1
CHANGELOG.md view
@@ -1,3 +1,8 @@+## Path IO 1.7.0++* Added `doesPathExist`, `getFileSize`, `renamePath`, and+ `removePathForcibly`.+ ## Path IO 1.6.3 * Fixed a bug that caused `removeDirLink` fail on Linux because of a
Path/IO.hs view
@@ -23,7 +23,9 @@ ensureDir, removeDir, removeDirRecur,+ removePathForcibly, renameDir,+ renamePath, listDir, listDirRel, listDirRecur,@@ -64,6 +66,7 @@ removeFile, renameFile, copyFile,+ getFileSize, findExecutable, findFile, findFiles,@@ -86,6 +89,7 @@ createTempDir, -- * Existence tests+ doesPathExist, doesFileExist, doesDirExist, isLocationOccupied,@@ -241,6 +245,27 @@ removeDirRecur :: MonadIO m => Path b Dir -> m () removeDirRecur = liftD D.removeDirectoryRecursive +-- | Remove a file or directory at /path/ together with its contents and+-- subdirectories. Symbolic links are removed without affecting their+-- targets. If the path does not exist, nothing happens.+--+-- Unlike other removal functions, this function will also attempt to delete+-- files marked as read-only or otherwise made unremovable due to permissions.+-- As a result, if the removal is incomplete, the permissions or attributes on+-- the remaining files may be altered. If there are hard links in the+-- directory, then permissions on all related hard links may be altered.+--+-- If an entry within the directory vanishes while @removePathForcibly@ is+-- running, it is silently ignored.+--+-- If an exception occurs while removing an entry, @removePathForcibly@ will+-- still try to remove as many entries as it can before failing with an+-- exception. The first exception that it encountered is re-thrown.+--+-- @since 1.7.0+removePathForcibly :: MonadIO m => Path b t -> m ()+removePathForcibly = liftD D.removePathForcibly+ -- | @'renameDir' old new@ changes the name of an existing directory from -- @old@ to @new@. If the @new@ directory already exists, it is atomically -- replaced by the @old@ directory. If the @new@ directory is neither the@@ -295,6 +320,51 @@ m () renameDir = liftD2 D.renameDirectory +-- | Rename a file or directory. If the destination path already exists, it+-- is replaced atomically. The destination path must not point to an existing+-- directory. A conformant implementation need not support renaming files in+-- all situations (e.g. renaming across different physical devices), but the+-- constraints must be documented.+--+-- The operation may fail with:+--+-- * @HardwareFault@+-- A physical I\/O error has occurred.+-- @[EIO]@+--+-- * @InvalidArgument@+-- Either operand is not a valid file name.+-- @[ENAMETOOLONG, ELOOP]@+--+-- * 'isDoesNotExistError'+-- The original file does not exist, or there is no path to the target.+-- @[ENOENT, ENOTDIR]@+--+-- * 'isPermissionError'+-- The process has insufficient privileges to perform the operation.+-- @[EROFS, EACCES, EPERM]@+--+-- * 'System.IO.isFullError'+-- Insufficient resources are available to perform the operation.+-- @[EDQUOT, ENOSPC, ENOMEM, EMLINK]@+--+-- * @UnsatisfiedConstraints@+-- Implementation-dependent constraints are not satisfied.+-- @[EBUSY]@+--+-- * @UnsupportedOperation@+-- The implementation does not support renaming in this situation.+-- @[EXDEV]@+--+-- * @InappropriateType@+-- Either the destination path refers to an existing directory, or one of the+-- parent segments in the destination path is not a directory.+-- @[ENOTDIR, EISDIR, EINVAL, EEXIST, ENOTEMPTY]@+--+-- @since 1.7.0+renamePath :: MonadIO m => Path b0 t -> Path b1 t -> m ()+renamePath = liftD2 D.renamePath+ -- | @'listDir' dir@ returns a list of /all/ entries in @dir@ without the -- special entries (@.@ and @..@). Entries are not sorted. --@@ -1175,6 +1245,12 @@ m () copyFile = liftD2 D.copyFile +-- | Obtain the size of a file in bytes.+--+-- @since 1.7.0+getFileSize :: MonadIO m => Path b File -> m Integer+getFileSize = liftD D.getFileSize+ -- | Given an executable file name, search for such file in the directories -- listed in system @PATH@. The returned value is the path to the found -- executable or 'Nothing' if an executable with the given name was not@@ -1528,6 +1604,14 @@ ---------------------------------------------------------------------------- -- Existence tests++-- | Test whether the given path points to an existing filesystem object. If+-- the user lacks necessary permissions to search the parent directories,+-- this function may return false even if the file does actually exist.+--+-- @since 1.7.0+doesPathExist :: MonadIO m => Path b t -> m Bool+doesPathExist = liftD D.doesPathExist -- | The operation 'doesFileExist' returns 'True' if the argument file -- exists and is not a directory, and 'False' otherwise.
path-io.cabal view
@@ -1,11 +1,11 @@-cabal-version: 1.18+cabal-version: 2.4 name: path-io-version: 1.6.3-license: BSD3+version: 1.7.0+license: BSD-3-Clause license-file: LICENSE.md maintainer: Mark Karpov <markkarpov92@gmail.com> author: Mark Karpov <markkarpov92@gmail.com>-tested-with: ghc ==8.8.4 ghc ==8.10.4 ghc ==9.0.1+tested-with: ghc ==8.10.7 ghc ==9.0.2 ghc ==9.2.1 homepage: https://github.com/mrkkrp/path-io bug-reports: https://github.com/mrkkrp/path-io/issues synopsis: Interface to ‘directory’ package for users of ‘path’@@ -35,10 +35,10 @@ dlist >=0.8 && <2.0, exceptions >=0.8 && <0.11, filepath >=1.2 && <1.5,- path >=0.6 && <0.9,+ path >=0.6 && <0.10, temporary >=1.1 && <1.4,- time >=1.4 && <1.11,- transformers >=0.3 && <0.6,+ time >=1.4 && <1.13,+ transformers >=0.3 && <0.7, unix-compat if flag(dev)@@ -63,9 +63,9 @@ exceptions >=0.8 && <0.11, hspec >=2.0 && <3.0, filepath >=1.2 && <1.5,- path >=0.6 && <0.9,+ path >=0.6 && <0.10, path-io,- transformers >=0.3 && <0.6,+ transformers >=0.3 && <0.7, unix-compat if flag(dev)
tests/Main.hs view
@@ -16,6 +16,9 @@ main :: IO () main = hspec . around withSandbox $ do++{- ORMOLU_DISABLE -}+ #ifndef mingw32_HOST_OS beforeWith populatedDir $ do -- NOTE These tests fail on Windows as unix-compat does not implement@@ -37,7 +40,6 @@ describe "setCurrentDir" setCurrentDirSpec describe "withCurrentDir" withCurrentDirSpec describe "walkDirRel" walkDirRelSpec- #ifndef mingw32_HOST_OS -- NOTE We can't quite test this on Windows as well, because the -- environmental variables HOME and TMPDIR do not exist there.@@ -47,6 +49,8 @@ describe "getXdgDir Config" getXdgConfigDirSpec describe "getXdgDir Cache" getXdgCacheDirSpec #endif++{- ORMOLU_ENABLE -} listDirSpec :: SpecWith (Path Abs Dir) listDirSpec = it "lists directory" $ \dir ->