🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by Zoran Pjevic Wed, 15 Sep 2004 12:45
How to prevent the filechooser resolving symblic links
#1021
Author: Zoran Pjevic
Date: Wed, 15 Sep 2004 12:45
24 lines
1491 bytes
Hello everybody

I am using a filechooser object to select files.

JFileChooser _fileChooser =  new JFileChooser();
File[] selectedfiles = _fileChooser.getSelectedFiles();

for (int i =0 ; i < selectedfiles.length; i++) {
   //path = selectedfiles[i].getCanonicalPath();
   path = selectedfiles[i].getPath();
}

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.

Is there a way to accomplish this?

Any help I will welcome.

Thanks in advance,
Zoran
Re: How to prevent the filechooser resolving symblic links
#1024
Author: John McGrath [TeamB]
Date: Tue, 21 Sep 2004 02:21
36 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads