streaming-commons 0.1.2 → 0.1.2.1
raw patch · 3 files changed
+19/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/Streaming/Filesystem.hs +6/−3
- streaming-commons.cabal +1/−1
- test/Data/Streaming/FilesystemSpec.hs +12/−0
Data/Streaming/Filesystem.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE ScopedTypeVariables #-} -- | Streaming functions for interacting with the filesystem. module Data.Streaming.Filesystem ( DirStream@@ -60,6 +61,7 @@ import System.Posix.Directory (DirStream, openDirStream, closeDirStream) import qualified System.Posix.Directory as Posix import qualified System.Posix.Files as PosixF+import Control.Exception (try, IOException) readDirStream :: DirStream -> IO (Maybe FilePath) readDirStream ds = do@@ -78,9 +80,10 @@ | PosixF.isRegularFile s -> return FTFile | PosixF.isDirectory s -> return FTDirectory | PosixF.isSymbolicLink s -> do- s' <- PosixF.getFileStatus fp- case () of- ()+ es' <- try $ PosixF.getFileStatus fp+ case es' of+ Left (_ :: IOException) -> return FTOther+ Right s' | PosixF.isRegularFile s' -> return FTFileSym | PosixF.isDirectory s' -> return FTDirectorySym | otherwise -> return FTOther
streaming-commons.cabal view
@@ -1,5 +1,5 @@ name: streaming-commons-version: 0.1.2+version: 0.1.2.1 synopsis: Common lower-level functions needed by various streaming data libraries description: Provides low-dependency functionality commonly needed by various streaming data libraries, such as conduit and pipes. homepage: https://github.com/fpco/streaming-commons
test/Data/Streaming/FilesystemSpec.hs view
@@ -43,6 +43,18 @@ ft <- getFileType "tmp" _ <- tryIO $ removeLink "tmp" ft `shouldBe` FTOther+ it "recursive symlink is other" $ do+ _ <- tryIO $ removeLink "tmp"+ createSymbolicLink "tmp" "tmp"+ ft <- getFileType "tmp"+ _ <- tryIO $ removeLink "tmp"+ ft `shouldBe` FTOther+ it "dangling symlink is other" $ do+ _ <- tryIO $ removeLink "tmp"+ createSymbolicLink "doesnotexist" "tmp"+ ft <- getFileType "tmp"+ _ <- tryIO $ removeLink "tmp"+ ft `shouldBe` FTOther tryIO :: IO a -> IO (Either IOException a) tryIO = try