Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

access contents of Shortcut + java File

 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I want to access

FOLDER
|_ File1
|_ File2
|_ Shortucut to some folder


Problem... how can i access the files in the Shortcut.

Regards
 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
still no solutions... ?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't really do it from pure Java. The file format is undocumented. People have reverse engineered parts of it, but I believe (and my memory may be wrong) that you can't really use the information therein from Java; you need to make Win32 calls -- i.e., JNI, Java native methods -- to use it.

The bloody JFileChooser didn't even support shortcuts until Tiger!
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Ernest pointed out, this seems specific to the operating system.

I did some experimenting with a folder alias on my Mac, and couldn't find a way in Java to get much out of it. (Represented as a File object, the alias appears to be a file rather than a directory, but the length is zero.)
 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys,

For clearing alot of thoughts, i had be scanning the API to find a suitable method. anyways that gives me my answer.

SUN should provide a method that returns the Target location of a file object.Which means that in case where its a directory it just provides the absolute path ot it and in case its a shortcut it provides an absolute path to the location of the dir. Just a thought.

Regards
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Linux these are called links, although there are two different kinds: hard links and symbolic links. Since all files have at least one hard link, they don'g cause any problems. A symbolic link to a directory behaves exactly the same as an actual directory as far as the File class is concerned. I'm not sure about symbolic links to other types of files, but I think they behave the same as well. Most likely this has nothing to do with Java or the File class but is handled at the OS level in such a way that File is quite seamless. Unfortunately, not all operating systems are smart enough to handle files so well.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic