This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Identifying if a File is a Softlink.

 
Parth Bhatt
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I am looking for a way to identify if a disk file, represented by an object of the File class, is a softlink or not.

Basically, I am working on a File Search utility that recursively browses the file structure on a unix machine to find a file with a particular name. The Problem that i am facing is with softlinks. i.e. my prog enters into an infinite loop when it encounters a softlink. For e.g. if a softlink /root/.openoffice/user/work points to /root directory, my program would enter into an infinite loop as everytime it encoulters /root/.openoffice/user/work it sould actually get into /root directory.

If some one can provide a solution or a web-link that throws some ligt on this issue... Thanks is advance...

Regards,
Parth Bhatt
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JConfig library can do this.

Interestingly, on OS X, the File.isFile and isDirectory methods report that a link to a directory is a directory, while an alias to a directory is a file. Quite confusing.
[ May 09, 2007: Message edited by: Ulf Dittmer ]
 
Parth Bhatt
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf...!!

JConfig seems to be great...

Since my requirement is only to find out if a file is a SoftLink or not, i wrote a /* bit lame */ piece of code, which works as follows :



 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic