English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] unix.chop_extension
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-05-29 (16:03)
From: David Brown <caml-list@d...>
Subject: Re: [Caml-list] unix.chop_extension
On Sat, May 29, 2004 at 08:01:10PM +1000, skaller wrote:

> It also isn't entirely clear how you would actually
> *measure* 'same result' in all cases -- normally
> this is obvious, but there will be nasty cases:
> the problem is that it is the nasty cases that
> are at issue here. opening x and ./x isn't
> the same thing on Unix due to permissions distinctions?

What nasty case are you thinking of?  Opening both "x" and "./x" will
require search (x) permission on the current directory, and will either
both work, or both fail in the same situations.

However, that is about the only "equivalent" path that is really
equivalent.  "foo/../x" and "x" may not be equivalent from a permission
perspective (or not at all, say if 'foo' is a symlink).

A good description might be: there are many paths that can possibly
refer to the same file.  A string manipulation library routine can
certainly come up with pathnames that are potentially equivalent.  To
determine real equivalence, something like 'realpath' should be used.
Of course, according to the Linux manpage for realpath:

  "Never use this function.  It is broken by design since it is
  impossible to determine a suitable size for the output buffer."

It wouldn't be very hard to implement realpath in ocaml, just using the
Unix module.  It could even be done safely :-)


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