packages feed

path-io 1.6.2 → 1.6.3

raw patch · 5 files changed

+57/−34 lines, 5 filesdep ~basedep ~pathdep ~time

Dependency ranges changed: base, path, time, transformers

Files

CHANGELOG.md view
@@ -1,3 +1,12 @@+## Path IO 1.6.3++* Fixed a bug that caused `removeDirLink` fail on Linux because of a+  trailing slash that used to be passed to the underlying+  `removeDirectoryLink` function from the `directory` package. [Issue+  59](https://github.com/mrkkrp/path-io/issues/59).++* Works with GHC 9.0.1.+ ## Path IO 1.6.2  * Fixed a bug in the `findFilesWith` and based on it `findFiles` functions.
Path/IO.hs view
@@ -13,7 +13,7 @@ -- Portability :  portable -- -- This module provides an interface to "System.Directory" for users of the--- "Path" module. It also implements commonly used primitives like recursive+-- "Path" module. It also implements some extra functionality like recursive -- scanning and copying of directories, working with temporary -- files\/directories, etc. module Path.IO@@ -482,7 +482,7 @@       then do         target <- getSymlinkTarget srcDir         D.createDirectoryLink target $-          F.dropTrailingPathSeparator (toFilePath destDir)+          toFilePath' destDir       else ensureDir destDir     when preserveDirPermissions $       ignoringIOErrors (copyPermissions srcDir destDir)@@ -1324,7 +1324,7 @@   m () createDirLink target' dest' = do   let target = toFilePath target'-      dest = F.dropTrailingPathSeparator (toFilePath dest')+      dest = toFilePath' dest'   liftIO $ D.createDirectoryLink target dest  -- | Remove an existing /directory/ symbolic link.@@ -1359,7 +1359,7 @@   -- | Symlink path   Path b t ->   m FilePath-getSymlinkTarget = liftD (D.getSymbolicLinkTarget . F.dropTrailingPathSeparator)+getSymlinkTarget = liftD D.getSymbolicLinkTarget  -- | Check whether the path refers to a symbolic link.  An exception is thrown -- if the path does not exist or is inaccessible.@@ -1374,7 +1374,7 @@ -- -- @since 1.3.0 isSymlink :: MonadIO m => Path b t -> m Bool-isSymlink = liftD (D.pathIsSymbolicLink . F.dropTrailingPathSeparator)+isSymlink = liftD D.pathIsSymbolicLink  ---------------------------------------------------------------------------- -- Temporary files and directories@@ -1697,8 +1697,8 @@ ---------------------------------------------------------------------------- -- Helpers --- | Lift action in 'IO' that takes 'FilePath' into action in slightly more--- abstract monad that takes 'Path'.+-- | Lift an action in 'IO' that takes 'FilePath' into an action in slightly+-- more abstract monad that takes 'Path'. liftD ::   MonadIO m =>   -- | Original action@@ -1707,10 +1707,10 @@   Path b t ->   -- | Lifted action   m a-liftD m = liftIO . m . toFilePath+liftD m = liftIO . m . toFilePath' {-# INLINE liftD #-} --- | Similar to 'liftD' for functions with arity 2.+-- | Similar to 'liftD' but for functions with arity 2. liftD2 ::   MonadIO m =>   -- | Original action@@ -1720,10 +1720,10 @@   -- | Second 'Path' argument   Path b1 t1 ->   m a-liftD2 m a b = liftIO $ m (toFilePath a) (toFilePath b)+liftD2 m a b = liftIO $ m (toFilePath' a) (toFilePath' b) {-# INLINE liftD2 #-} --- | Similar to 'liftD2', but allows to pass second argument of arbitrary+-- | Similar to 'liftD2', but allows us to pass second argument of arbitrary -- type. liftD2' ::   MonadIO m =>@@ -1734,8 +1734,12 @@   -- | Second argument   v ->   m a-liftD2' m a v = liftIO $ m (toFilePath a) v+liftD2' m a v = liftIO $ m (toFilePath' a) v {-# INLINE liftD2' #-}++-- | Like 'toFilePath', but also drops the trailing path separator.+toFilePath' :: Path b t -> FilePath+toFilePath' = F.dropTrailingPathSeparator . toFilePath  -- | Perform an action ignoring IO exceptions it may throw. ignoringIOErrors :: IO () -> IO ()
README.md view
@@ -8,8 +8,8 @@  This package provides an interface to the [`directory`](https://hackage.haskell.org/package/directory) package for-users of Chris Done's [`path`](https://hackage.haskell.org/package/path). It-also implements some missing stuff like recursive scanning and copying of+users of [`path`](https://hackage.haskell.org/package/path). It also+implements some extra functionality like recursive scanning and copying of directories, working with temporary files/directories, etc.  Consult Haddocks for usage, which should be trivial.
path-io.cabal view
@@ -1,11 +1,11 @@ cabal-version:   1.18 name:            path-io-version:         1.6.2+version:         1.6.3 license:         BSD3 license-file:    LICENSE.md maintainer:      Mark Karpov <markkarpov92@gmail.com> author:          Mark Karpov <markkarpov92@gmail.com>-tested-with:     ghc ==8.6.5 ghc ==8.8.4 ghc ==8.10.2+tested-with:     ghc ==8.8.4 ghc ==8.10.4 ghc ==9.0.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’@@ -29,8 +29,8 @@     exposed-modules:  Path.IO     default-language: Haskell2010     build-depends:-        base >=4.12 && <5.0,-        containers -any,+        base >=4.13 && <5.0,+        containers,         directory >=1.3.2.0 && <1.4,         dlist >=0.8 && <2.0,         exceptions >=0.8 && <0.11,@@ -39,7 +39,7 @@         temporary >=1.1 && <1.4,         time >=1.4 && <1.11,         transformers >=0.3 && <0.6,-        unix-compat -any+        unix-compat      if flag(dev)         ghc-options: -Wall -Werror@@ -58,15 +58,15 @@     hs-source-dirs:   tests     default-language: Haskell2010     build-depends:-        base >=4.12 && <5.0,+        base >=4.13 && <5.0,         directory >=1.3.2.0 && <1.4,         exceptions >=0.8 && <0.11,         hspec >=2.0 && <3.0,         filepath >=1.2 && <1.5,         path >=0.6 && <0.9,-        path-io -any,+        path-io,         transformers >=0.3 && <0.6,-        unix-compat -any+        unix-compat      if flag(dev)         ghc-options: -Wall -Werror
tests/Main.hs view
@@ -18,8 +18,8 @@ main = hspec . around withSandbox $ do #ifndef mingw32_HOST_OS   beforeWith populatedDir $ do-    -- NOTE These tests shall fail on Windows as unix-compat does not-    -- implement createSymbolicLink for windows.+    -- NOTE These tests fail on Windows as unix-compat does not implement+    -- createSymbolicLink for windows.     describe "listDir"          listDirSpec     describe "listDirRel"       listDirRelSpec     describe "listDirRecur"     listDirRecurSpec@@ -29,6 +29,7 @@     describe "copyDirRecur"     copyDirRecurSpec     describe "copyDirRecur'"    copyDirRecur'Spec     describe "findFile"         findFileSpec+    describe "removeDirLink"    removeDirLinkSpec   beforeWith populatedCyclicDir $     describe "listDirRecur Cyclic" listDirRecurCyclicSpec #endif@@ -89,10 +90,11 @@     f' <- filterM filePred f     return (d', f') --- | walkDir with a Finish handler may have unpredictable output depending on--- the order of traversal. The only guarantee is that we will finish only after--- we find the directory "c". Though if we test only for the presence of "c" we--- are not really testing if we indeed cut the traversal short.+-- | 'walkDir' with a 'WalkFinish' handler may have unpredictable output+-- depending on the order of traversal. The only guarantee is that we will+-- finish only after we find the directory "c". Though if we test only for+-- the presence of "c" we are not really testing if we indeed cut the+-- traversal short. walkDirFinishSpec :: SpecWith (Path Abs Dir) walkDirFinishSpec =   it "Finishes only after finding what it is looking for" $ \dir -> do@@ -143,13 +145,22 @@   found <- findFile (dir : undefined) relFile   found `shouldBe` Just (dir </> relFile) +removeDirLinkSpec :: SpecWith (Path Abs Dir)+removeDirLinkSpec = it "remove dir link" $ \dir -> do+  let target = dir </> $(mkRelDir "a")+      link = dir </> $(mkRelDir "link-a")+  createDirLink target link+  removeDirLink link+  exists <- doesDirExist link+  exists `shouldBe` False+ listDirRecurCyclicSpec :: SpecWith (Path Abs Dir) listDirRecurCyclicSpec =   it "lists directory trees having traversal cycles" $ \dir ->     getDirStructure listDirRecurCyclic dir       `shouldReturn` populatedCyclicDirStructure --- Follows symbolic links+-- | Follows symbolic links. listDirRecurCyclic ::   (MonadIO m, MonadThrow m) =>   -- | Directory to list@@ -244,9 +255,8 @@ -- Helpers  -- | Create a sandbox directory to model some situation in it and run some--- tests. Note that we're using new unique sandbox directory for each test--- case to avoid contamination and it's unconditionally deleted after test--- case finishes.+-- tests. Note that we're using a new unique sandbox directory for each test+-- case and it's unconditionally deleted after test case finishes. withSandbox :: ActionWith (Path Abs Dir) -> IO () withSandbox = withSystemTempDir "path-io-sandbox" @@ -268,8 +278,8 @@   forM_ files $ (`writeFile` "") . toFilePath . withinSandbox   return pdir --- | Get inner structure of a directory. Items are sorted, so it's easier to--- compare results.+-- | Get the inner structure of a directory. Items are sorted, so it's+-- easier to compare results. getDirStructure ::   -- | Which function to use for scanning   (Path Abs Dir -> IO ([Path Abs Dir], [Path Abs File])) ->