packages feed

pipes-files 0.1.0 → 0.1.1

raw patch · 4 files changed

+26/−4 lines, 4 filesdep ~semigroups

Dependency ranges changed: semigroups

Files

Helper.c view
@@ -9,7 +9,11 @@  unsigned int __hscore_d_namlen( struct dirent* d ) {+#ifdef _DIRENT_HAVE_D_NAMLEN   return d->d_namlen;+#else+  return strlen(d->d_name);+#endif }  int __hscore_readdir_r(DIR * dir, struct dirent * d, struct dirent ** dp)
Pipes/Files.hs view
@@ -545,15 +545,15 @@         Left (_ :: IOException) -> return ()             -- liftIO $ putStrLn $             --     "Error reading directory " ++ path ++ ": " ++ show e-        Right entries -> forM_ entries $ \entry ->-            unless (entry `elem` [".", ".."]) $ do+        Right entries ->+            forM_ (filter (`notElem` [".", ".."]) entries) $ \entry -> do                 let fullPath = path ++ "/" ++ entry                 estat <- liftIO $ E.try $ getFileStatus fullPath                 case estat of                     Left (_ :: IOException) -> return ()                     Right st ->                         yield (fullPath :< if isDirectory st-                                           then Just (directoryFiles fullPath)+                                           then Just $ directoryFiles fullPath                                            else Nothing)  genericFindFiles
Pipes/Files/Directory.hs view
@@ -1,5 +1,7 @@+{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE RankNTypes #-}@@ -51,6 +53,22 @@             ".." -> readDir acc ds direntp             _    -> readDir (res:acc) ds direntp {-# INLINE getDirectoryContentsAndAttrs #-}++data Step s o r = Emit s o | Skip s | Stop r+    deriving Functor++data Stream o m r = forall s. Stream (s -> m (Step s o r)) (m s)++streamDirectoryAndAttrs :: RawFilePath -> Stream (RawFilePath, CUInt) IO ()+streamDirectoryAndAttrs path = Stream step (openDirStream path)+  where+    step ds = allocaBytes (fromIntegral c_sizeof_dirent) $ \direntp -> do+        res <- readDirStream ds direntp+        case fst res of+            ""   -> Stop () <$ closeDirStream ds+            "."  -> return $ Skip ds+            ".." -> return $ Skip ds+            _    -> return $ Emit ds res  sourceDirectory :: MonadSafe m                 => RawFilePath -> Producer (RawFilePath, CUInt) m ()
pipes-files.cabal view
@@ -1,5 +1,5 @@ name:          pipes-files-version:       0.1.0+version:       0.1.1 synopsis:      Fast traversal of directory trees using pipes description:   Fast traversal of directory trees using pipes homepage:      https://github.com/jwiegley/pipes-files