Article View: borland.public.jbuilder.java.swing
Article #1024Re: How to prevent the filechooser resolving symblic links
From: John McGrath [TeamB]
Date: Tue, 21 Sep 2004 02:21
Date: Tue, 21 Sep 2004 02:21
36 lines
2435 bytes
2435 bytes
On 9/15/2004 at 8:45:04 AM, Zoran Pjevic wrote:
> I am using a filechooser object to select files.
> The _fileChooser.getSelectedFiles() returns already absolute path
> names. So no matter if I call getPath or getCanocialPath I get the
> abosolute path names.
>
> But I want to display symbolic links as relative pathnames.
Assuming that JFileChooser did return relative paths, it is not very clear
what directory the paths would be relative to. It could be the initial
current directory set on the JFileChooser, although that changes based on
user input and possibly based on other code behavior. It could also be
the current value of the "user.dir" system property or the operating
system's "current working directory", assuming that was defined.
> Is there a way to accomplish this?
I think you will need to write your own getPathRelativeTo(File, File)
method. Be aware that there are some tricky issues here. If there are
symbolic links (or other filesystem oddities) on your path, it may not be
too clear what relative path should be returned. It could return a path
containing the symbolic link, or one based on the canonical path for the
specified path. Also, you need to consider the possibility that there is
no possible relative path, but you probably just want to return an
absolute path in that case.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<414f902f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<dpdgk0524l0g2f41rt1fiein9cj6t7lj4p@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,8eb7d817b4177417 X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit From: "John McGrath [TeamB]" <ng-b@JPMcGrath.net> Subject: Re: How to prevent the filechooser resolving symblic links Newsgroups: borland.public.jbuilder.java.swing References: <dpdgk0524l0g2f41rt1fiein9cj6t7lj4p@4ax.com> User-Agent: XanaNews/1.16.4.2 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 NNTP-Posting-Host: 141.151.8.31 Message-ID: <414f902f$1@newsgroups.borland.com> Date: 20 Sep 2004 19:21:35 -0700 X-Trace: newsgroups.borland.com 1095733295 141.151.8.31 (20 Sep 2004 19:21:35 -0700) Lines: 36 X-Authenticated-User: jpmcgrath Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail