ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wannheden, Knut" <knut.wannhe...@paranor.ch>
Subject RE: FileUtils#normalize(File)
Date Wed, 30 Jul 2003 08:38:19 GMT
Stefan,

> > I've noticed that the normalize(File) method in FileUtils requires
> > that the File to normalize is absolute.  I was wondering what the
> > reason is for this reason.
> 
> I'm not entirely sure (we extracted the code from Project way back
> IIRC).  On problem I can imagine is that of relative paths that go up
> beyond "", something like normalize("../../foo").
> 

You currently have the same problem with a path like "/../foo", even though
a Unix system would return "/foo" in a case like this.

> > Even a path like "../foo" could be normalized using the system
> > property "user.dir",
> 
> No, most invocations of normalize happen from resolveFile, so you
> already know which absolute directory to resolve against.  ${user.dir}
> is almost always wrong for Ant's own usage.
> 

If you know what directory to resolve against, even the better.  Then you
can from resolveFile(file, filename) do something like normalize(new
File(file, filename)).  As it is now these two methods have quite a bit of
common code.

But this is really a minor issue, so maybe it's not worth bothering.

--
knut

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message