From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA18200; Tue, 25 May 2004 23:19:40 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA18094 for ; Tue, 25 May 2004 23:19:37 +0200 (MET DST) From: sylvain.le-gall@polytechnique.org Received: from corwin.easynet.fr (corwin.easynet.fr [212.180.1.123]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i4PLJaSH007874 for ; Tue, 25 May 2004 23:19:36 +0200 Received: from asi-62.asi256ip.easynet.fr ([212.180.39.62] helo=gros) by corwin.easynet.fr with esmtp (Exim 4.34) id 1BSjKi-0000BI-1i; Tue, 25 May 2004 23:19:36 +0200 Received: from ptit ([192.168.0.11] helo=ptit.gallu.homelinux.org) by gros with esmtp (Exim 3.36 #1 (Debian)) id 1BSjKh-0007HS-00; Tue, 25 May 2004 23:19:35 +0200 Received: from gildor by ptit.gallu.homelinux.org with local (masqmail 0.2.20) id 1BSjKd-5tZ-00; Tue, 25 May 2004 23:19:31 +0200 Date: Tue, 25 May 2004 23:19:31 +0200 To: skaller Cc: Ocaml Subject: Re: [Caml-list] lstat on windows native Message-ID: <20040525211931.GA22624@gallu.homelinux.org> Mail-Followup-To: skaller , Ocaml References: <1085470849.6065.457.camel@pelican.wigram> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1085470849.6065.457.camel@pelican.wigram> User-Agent: Mutt/1.5.6i X-Miltered: at concorde with ID 40B3B868.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; le-gall:01 caml-list:01 2004:99 implemented:01 3.07:01 32,:01 recursively:01 recursion:01 ..,:01 symlink:01 usr:01 usr:01 subdirectory:01 implemented:01 natively:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, 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 ocaml-fileutils. 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 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