[Haskell-beginners] problem with System.Directory.Tree

Anand Mitra mitra at kqinfotech.com
Mon Jun 7 20:46:34 EDT 2010


Hi Daniel,

That works just as intended, Thanks.

On Tue, Jun 8, 2010 at 1:31 AM, Daniel Fischer <daniel.is.fischer at web.de>wrote:

>
> Does
>
> calcMD5 =
>    readDirectoryWith (\x -> do
>        txt <- readFile x
>        return $! md5 txt)
>
> help?
>
> >
> > `----
> >
> > This work perfectly for small directories. readDirectoryWith is
> > already defined in the library and exactly what we want
> >
> > ,----
> >
> > | *Main> calcMD5 "/home/mitra/Desktop/"
> > |
> > | "/home/mitra" :/ Dir {name = "Desktop", contents = [File {name =
> > | "060_LocalMirror_Workflow.t.10.2.62.9.log", file =
> > | f687ad04bc64674134e55c9d2a06902a},File {name = "cmd_run", file =
> > | 6f334f302b5c0d2028adeff81bf2a0d9},File {name = "cmd_run~",
> >
> > `----
> >
> > However when ever I give it something more challenging it gets into
> > trouble.
> >
> > ,----
> >
> > | *Main> calcMD5 "/home/mitra/laptop/"
> > | *** Exception: /home/mitra/laptop/ell/calc-2.02f/calc.info-27:
> > |    openFile: resource exhausted (Too many open files)
> > | *Main> 29~
> >
> > `----
> >
> > If I understand what is happening it seems to be doing all the opens
> > before consuming them via md5. This works fine for small directories
> > but for any practical setup this could potentially be very large. I
> > tried forcing the md5 evaluation in the hope that the file descriptor
> > will be freed once the entire file is read. That did not help, either
> > because I could not get it right or there is some more subtle I am
> > missing.
> >
> > I also had a look at the code in module "System.Directory.Tree" and
> > although it gave me some understanding of how it works I am no closer
> > to a solution.
> >
> > regards
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100607/9c3faa38/attachment-0001.html


More information about the Beginners mailing list