* [Caml-list] lstat on windows native @ 2004-05-25 7:40 skaller 2004-05-25 8:55 ` Olivier Andrieu ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: skaller @ 2004-05-25 7:40 UTC (permalink / raw) To: Ocaml 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 [Felix can actually do that, since the constant folder guarrantees to reduce conditionals over constants in a somewhat vain attempt to reduce the need for preprocessor based conditional compilation] -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] lstat on windows native 2004-05-25 7:40 [Caml-list] lstat on windows native skaller @ 2004-05-25 8:55 ` Olivier Andrieu 2004-05-25 9:41 ` skaller 2004-05-25 10:20 ` Peter Jolly 2004-05-25 21:19 ` sylvain.le-gall 2 siblings, 1 reply; 7+ messages in thread From: Olivier Andrieu @ 2004-05-25 8:55 UTC (permalink / raw) To: skaller; +Cc: caml-list skaller [25 May 2004]: > 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. No, using unimplemented features of the Unix module will never prevent your program to compile nor link. The module signature is the same on all platforms. However, it will probably raise an exception at runtime (like Invalid_argument "foo not implemented"). Concerning lstat, it is a bit different, lstat is defined as: let lstat = stat > if Sys.os_type = "Win32" then stat else lstat that's fine too, of course. -- Olivier ------------------- 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] lstat on windows native 2004-05-25 8:55 ` Olivier Andrieu @ 2004-05-25 9:41 ` skaller 2004-05-25 15:33 ` David Brown 0 siblings, 1 reply; 7+ messages in thread From: skaller @ 2004-05-25 9:41 UTC (permalink / raw) To: Olivier Andrieu; +Cc: caml-list On Tue, 2004-05-25 at 18:55, Olivier Andrieu wrote: > No, using unimplemented features of the Unix module will never prevent > your program to compile nor link. > The module signature is the same on > all platforms. However, it will probably raise an exception at runtime > (like Invalid_argument "foo not implemented"). Ah, ok .. that isn't what the documentation seems to imply by saying 'not implemented'. If you are correct, it *is* implemented, just having quite different semantics. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] lstat on windows native 2004-05-25 9:41 ` skaller @ 2004-05-25 15:33 ` David Brown 0 siblings, 0 replies; 7+ messages in thread From: David Brown @ 2004-05-25 15:33 UTC (permalink / raw) To: skaller; +Cc: Olivier Andrieu, caml-list On Tue, May 25, 2004 at 07:41:30PM +1000, skaller wrote: > Ah, ok .. that isn't what the documentation seems to imply > by saying 'not implemented'. If you are correct, > it *is* implemented, just having quite different > semantics. Since windows doesn't have symlinks the semantics of stat and lstat would be the same. Also, don't you need to ignore '.' and '..' on windows as well? They are at least present in the FAT filesystem, although the directory reading operations may not return them. Dave Brown ------------------- 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] lstat on windows native 2004-05-25 7:40 [Caml-list] lstat on windows native skaller 2004-05-25 8:55 ` Olivier Andrieu @ 2004-05-25 10:20 ` Peter Jolly 2004-05-25 21:19 ` sylvain.le-gall 2 siblings, 0 replies; 7+ messages in thread From: Peter Jolly @ 2004-05-25 10:20 UTC (permalink / raw) To: skaller; +Cc: caml-list 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. > > I wonder if this function can be implemented for Windows? > I'm not sure what it means (I don't understand Windows shortcuts). In the native Windows ocaml, all shortcuts stat as S_REG, so it's not a problem (for your purposes) that lstat == stat. In the Cygwin port, shortcuts are treated as symlinks, and stat and lstat treat them as documented. ------------------- 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] lstat on windows native 2004-05-25 7:40 [Caml-list] lstat on windows native skaller 2004-05-25 8:55 ` Olivier Andrieu 2004-05-25 10:20 ` Peter Jolly @ 2004-05-25 21:19 ` sylvain.le-gall 2004-05-26 7:19 ` skaller 2 siblings, 1 reply; 7+ messages in thread From: sylvain.le-gall @ 2004-05-25 21:19 UTC (permalink / raw) To: skaller; +Cc: Ocaml 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] lstat on windows native 2004-05-25 21:19 ` sylvain.le-gall @ 2004-05-26 7:19 ` skaller 0 siblings, 0 replies; 7+ messages in thread From: skaller @ 2004-05-26 7:19 UTC (permalink / raw) To: sylvain.le-gall; +Cc: Ocaml On Wed, 2004-05-26 at 07:19, sylvain.le-gall@polytechnique.org wrote: > Hello, > 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 ). That's nice but your code is GPL. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-05-26 7:19 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-05-25 7:40 [Caml-list] lstat on windows native skaller 2004-05-25 8:55 ` Olivier Andrieu 2004-05-25 9:41 ` skaller 2004-05-25 15:33 ` David Brown 2004-05-25 10:20 ` Peter Jolly 2004-05-25 21:19 ` sylvain.le-gall 2004-05-26 7:19 ` skaller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox