unliftio 0.2.15 → 0.2.16
raw patch · 4 files changed
+55/−2 lines, 4 files
Files
- ChangeLog.md +4/−0
- src/UnliftIO/Directory.hs +17/−0
- test/UnliftIO/DirectorySpec.hs +31/−0
- unliftio.cabal +3/−2
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for unliftio +## 0.2.16++* Add `createFileLink`+ ## 0.2.15 * Updated documentation mentioning that `MonadUnliftIO` may be derived using
src/UnliftIO/Directory.hs view
@@ -7,6 +7,9 @@ -- * Actions on directories createDirectory , createDirectoryIfMissing+#if MIN_VERSION_directory(1,3,1)+ , createFileLink+#endif , removeDirectory , removeDirectoryRecursive #if MIN_VERSION_directory(1,2,7)@@ -148,6 +151,20 @@ createDirectoryIfMissing :: MonadIO m => Bool -> FilePath -> m () createDirectoryIfMissing create_parents path0 = liftIO (D.createDirectoryIfMissing create_parents path0)++#if MIN_VERSION_directory(1,3,1)+-- | Lifted 'D.createFileLink'.+-- directory package version should be >= 1.3.1.+-- @since 0.2.16.0+{-# INLINE createFileLink #-}+createFileLink+ :: MonadIO m+ => FilePath -- ^ path to the target file+ -> FilePath -- ^ path of the link to be created+ -> m ()+createFileLink targetPath linkPath =+ liftIO (D.createFileLink targetPath linkPath)+#endif -- | Lifted 'D.removeDirectory'. --
+ test/UnliftIO/DirectorySpec.hs view
@@ -0,0 +1,31 @@+{-# LANGUAGE CPP #-}+module UnliftIO.DirectorySpec (spec) where++import Test.Hspec+#if MIN_VERSION_directory(1,3,1)+import System.FilePath+import UnliftIO.IO+import UnliftIO.Directory+import UnliftIO.Temporary+++spec :: Spec+spec = do+ describe "createFileLink" $ do+ it "mirror" $ do+ withSystemTempDirectory "createFileLink.mirror" $ \fp -> do+ let fileContent = "i am the same"+ fileContent' = "I AM THE SAME"+ origin = fp </> "origin.txt"+ link = fp </> "link.txt"+ writeFile origin fileContent+ createFileLink origin link+ linkContent <- readFile link+ linkContent `shouldBe`fileContent+ writeFile origin fileContent'+ linkContent' <- readFile link+ linkContent' `shouldBe`fileContent'+#else+spec :: Spec+spec = pure ()+#endif
unliftio.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 6f6fd7f95df930571d7c917424b5f1163381bfa922c0385872be54ccb48991cc+-- hash: 57462bd1ca0ffabd88cb1b743945f84d5c6330a59b7b364445e08d6399628d80 name: unliftio-version: 0.2.15+version: 0.2.16 synopsis: The MonadUnliftIO typeclass for unlifting monads to IO (batteries included) description: Please see the documentation and README at <https://www.stackage.org/package/unliftio> category: Control@@ -92,6 +92,7 @@ main-is: Spec.hs other-modules: UnliftIO.AsyncSpec+ UnliftIO.DirectorySpec UnliftIO.ExceptionSpec UnliftIO.IO.FileSpec UnliftIO.IOSpec