2009/9/9  <jan.mate...@rzf.fin-nrw.de>:
> The enhancement of <property location/> seems to be good candidate.
...
> <property location="my/file.txt" relative="true" basedir="my/dir"/>
> --> ../my/file.txt

../file.txt, surely?  my/dir + .. -> my, my/dir + ../my -> my/my,
my/dir + ../my/file.txt -> my/my/file.txt

You might also like to add a test case for

<property location="dir1/file.txt" relative="true" basedir="dir2"/>
--> ../dir1/file.txt

which I don't think is covered by the others.  Also, I notice all the
test cases you mentioned have a file as the location; I assume it'll
work the same way when location is a directory?  In which case, there
probably ought to be a test case for

<property location="my/dir" relative="true" basedir="my/dir"/>

probably expecting "." to be returned, though you could make a
reasonable argument in favour of "" instead.

Actually, that gives me a thought about the extra "../" I was seeing
with your earlier FileUtils.getRelativePath suggestion - could it be
that it assumes the first argument (the base for the relative path) is
always a directory?  That would explain why foo/1 -> foo/2 is returned
as ../2 rather than just 2, it's actually doing foo/1/ -> foo/2.  In
which case, your use of baseFile in the scriptdef was slightly
misleading, baseDir would have been a better name.
Alternatively, perhaps getRelativePath ought to check
File.isDirectory()/File.isFile() and adjust accordingly?


Andy
-- 
http://pseudoq.sourceforge.net/  Open source java sudoku application

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to