Browse thread
[Caml-list] Why do input* and readdir throw End_of_file ... annoying!
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Richard Jones <rich@a...> |
| Subject: | Re: [Caml-list] Why do input* and readdir throw End_of_file ... annoying! |
On Fri, Jun 06, 2003 at 09:03:38PM +0300, Ville-Pertti Keinonen wrote:
> Writing a try ... with statement isn't really that different from a
> match statement except for the fact that you can handle exceptional
> circumstances generated by several expressions in the with ... part of
> a try ... with statement - if anything, that's more permissive.
The problem is that there doesn't seem to be a way to write the
loop function using readdir. eg:
let rec loop () =
let filename = readdir dirh in
match filename with
| "." -> loop ()
| ".." -> loop ()
| filename ->
let pathname = path ^ "/" ^ filename in
let stat = lstat pathname in
let this = if stat.st_kind = S_DIR then
read_directory pathname
else
File pathname in
this :: loop ()
in
try
Directory (loop ())
with
End_of_file -> XXX what?
Because the exception is always raised (it's not an exception at all)
there's no way to return the result of the call to loop ().
Rich.
--
Richard Jones, Red Hat Inc. (London) and Merjis Ltd. http://www.merjis.com/
http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj
C2LIB is a library of basic Perl/STL-like types for C. Vectors, hashes,
trees, string funcs, pool allocator: http://www.annexia.org/freeware/c2lib/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners