Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Why do input* and readdir throw End_of_file ... annoying!
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-06-06 (18:43)
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
	  File pathname in
	this :: loop ()
    Directory (loop ())
    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 ().


Richard Jones, Red Hat Inc. (London) and Merjis Ltd. Freshmeat projects:
C2LIB is a library of basic Perl/STL-like types for C. Vectors, hashes,
trees, string funcs, pool allocator:

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: