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] lstat on windows native
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-05-25 (21:19)
From: sylvain.le-gall@p...
Subject: Re: [Caml-list] lstat on windows native

On Tue, May 25, 2004 at 05:40:49PM +1000, skaller wrote:
> Currently, I need to use lstat (as pointed out in previous
> email) but it isn't implemented on Windows native port
> according to 3.07 documentation.
> If I understand correctly this means my program won't
> compile/link on Win32, which isn't very nice.
> What I'm trying to do is somewhat problematic:
> recursively find all the files starting from
> a given directory. 
> I'm skipping over symbolic links to avoid duplication,
> infinite recursion with . and .., and because the user
> can specify a set of "root" directories, and therefore
> always add (the target of) a skipped symlink to the set.
> It is also possible to exclude bad directories/files.
> To fix this problem, I can use plain 'stat' and
> require the client to specify all exclusions/inclusions,
> and that will work on Windows and Unix, but it is
> *extremely ugly* because you'd have to exclude
> /usr/include/.
> /usr/include/..
> etc for every subdirectory ..
> I wonder if this function can be implemented for Windows?
> I'm not sure what it means (I don't understand Windows shortcuts).
> If a "proper" implementation can't be provided, I wonder
> if a "cheat" which simply defines it the same as 'stat'
> would make sense. At least my code would then work
> without requiring conditional compilation (which Ocaml
> doesn't support natively).
> I can detect the cheat by Sys.os_type dynamically
> and do special (less reliable OS dependent) processing,
> but of course I can't write:
> if Sys.os_type = "Win32" then stat else lstat

Well, i don't want to make publicity, but the function you are trying to
implement is already implemented in ocaml-fileutils ( recently annouced
on this list ).

You have a function "find" which can operate on windows and linux ( i
don't have fully test it on windows ). It does exactly what you need.

I don't think it will detect the symbolic link problem, but if you want
i can work on it, and solve the problem with all people using

Currently, ocaml-fileutils is under test, but i am responsive to any
attempt to improve this library.

Moreover, the semantic of the "find" function is exactly the same under
win32 and unix, you don't even have to switch any line of codes, since
it will be handled by a module "Default", which do the same detection as
you did.

If you need any function ( which can be useful for all ), i will be
happy to implement it for the next version of ocaml-fileutils.

Kind regard
Sylvain Le Gall

ps : you will find all reference, website, on The Hump ( FileUtils )

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