[Haskell-cafe] directory tree?

Chad Scherrer chad.scherrer at gmail.com
Mon Jun 25 14:47:11 EDT 2007


I downloaded your FileManip library and Duncan's zlib library, but I
kept getting a "Too many open files" exception (it matches over 9000
files). I tried to get around this using unsafeInterleaveIO as Greg
had suggested, so now I have this:

foo = namesMatching "*/*.z" >>=
      fmap B.concat . mapM (unsafeInterleaveIO . fmap decompress . B.readFile)

Now it doesn't complain about too many open files, but instead I get
this runtime error:

LPS *** Exception: user error (Codec.Compression.Zlib: incorrect header check)

I tried to get the same error on simpler code, and I've found this
gives the same error:

bar = fmap decompress $ L.readFile "myData.z"

It seemed to me the file might be corrupted, but I can do
gunzip -c  "myData.gz"

at the command line and see the results just fine.

I also tried gzipping a different, smaller file, and I changed the
string in "bar" accordingly. No error in that case. So it seems to be
a problem with myData.z, but why would it gunzip from the command line
with no trouble in that case?


On 6/24/07, Bryan O'Sullivan <bos at serpentine.com> wrote:
> Using my FileManip library, you'd do that like this.
> import Codec.Compression.GZip
> import qualified Data.ByteString.Lazy as B
> import System.FilePath.Glob
> foo :: IO B.ByteString
> foo = namesMatching "*/*.gz" >>=
>        fmap B.concat . mapM (fmap decompress . B.readFile)
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FileManip-0.2

More information about the Haskell-Cafe mailing list