Bug 23261 - enhance <available type="symbolic_link" />
Summary: enhance <available type="symbolic_link" />
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.5.3
Hardware: Other other
: P3 enhancement with 1 vote (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL: http://ant.apache.org/manual/CoreTask...
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-18 20:40 UTC by Ralf Hauser
Modified: 2018-06-01 14:30 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Hauser 2003-09-18 20:40:39 UTC
ok, again, it is mainly operating-system "native" but it would be nice to have
anyway!
Comment 1 _matthewHawthorne 2003-10-16 06:04:06 UTC
At a minimum, it would be nice if available returned true for symlinks.  Why
can't  it be treated like just another file?
Comment 2 peter reilly 2003-10-16 08:11:13 UTC
>> Why can't  it be treated like just another file?
Because java.io.File#isSymbolicFile() does not exist.
So symbolic files that point to directories are treated as
directories (java.io.File#isDirectory() returns true),
symbolic files that point to non-existant files are
treats as not present (java.io.File#exists() returns false)
Comment 3 Gus Heck 2003-10-16 15:46:32 UTC
However we do have org.apache.tools.ant.util.FileUtils.isSymbolicLink(File,
String). This is what is used in the <symlink> task. There are a number of
caveats to using it as noted in the javadoc:

     * <p>It doesn't really test for symbolic links but whether the
     * canonical and absolute paths of the file are identical - this
     * may lead to false positives on some platforms.</p>

However, the platform on which this gives a false positive has not (to my
knowledge) been found yet. 

I would say that this version of available is possible, but should carry the
same caveat until sun actually does provide a better interface to native file
systems, and then we can drop in a reflection to use a real test when the proper
vm is available. I might try to code this up if I have time this weekend, but no
guarantees and of course any1 who wants to do it or be sure it gets done is free
to beat me to it. :)
Comment 4 Ralf Hauser 2009-11-16 06:44:29 UTC
see also Bug 22370 

one option is just to always delete and recreate the symlink with 

http://ant.apache.org/manual/OptionalTasks/symlink.html

not really beautiful, but may be a work-around for some situations where one would test as RFE'd here
Comment 5 Gintas Grigelionis 2018-06-01 14:30:50 UTC
symlink selector is available in Ant 1.10