diff --git a/Helper.c b/Helper.c
--- a/Helper.c
+++ b/Helper.c
@@ -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)
diff --git a/Pipes/Files.hs b/Pipes/Files.hs
--- a/Pipes/Files.hs
+++ b/Pipes/Files.hs
@@ -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
diff --git a/Pipes/Files/Directory.hs b/Pipes/Files/Directory.hs
--- a/Pipes/Files/Directory.hs
+++ b/Pipes/Files/Directory.hs
@@ -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 ()
diff --git a/pipes-files.cabal b/pipes-files.cabal
--- a/pipes-files.cabal
+++ b/pipes-files.cabal
@@ -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
