Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to determine if a file is an alias



Mark Noble wrote:

>Is there any way to determine if a file is an alias from Java?

That depends on what you mean by "from Java".

Werner already noted his JNI-based Java function for testing aliases.  Mine
is a more extensive file-handling facility, provided in the open source
MacBinary Toolkit for Java:
  <http://www.amug.org/~glguerin/sw/#macbinary>

The class FileForker is given a Pathname and then queried for isAlias()
and/or isSymlink().

You may then resolve the alias or symlink with selfResolve() or
makeResolved().  That's answering a question you didn't ask, so skip it if
you don't want to resolve the alias.


If you want to test for alias-files using no additional libraries, just
plain ordinary J2SE, that's a lot harder.  And if you want to resolve
alias-files without an additional library, that's harder still.


>I have also tried checking the canonical path of the file against the path
>of the file against the actual path of the file. Which does not seem to
>work (although this does work on other systems).

Alias-files, which are distinct from symlinks, are not resolved by
getCanonicalPath() on Mac OS X.  That's the way Apple thinks it should be,
because I filed a bug-report on it with 10.0 and it was closed as "works as
intended", or whatever the polite yet terse denial is.

Resolving symlinks with getCanonicalPath() does work on Mac OS X.  It works
on other Unix platforms, too.  I don't recall whether getCanonicalPath()
resolves shortcut files (.LNK) on Windows or not, but there was a time when
it did not.  I just haven't checked for a few years.

Since other platforms don't have alias-files in the same way that Mac OS X
does, nor with the symlink/alias-file distinction, you'll have to be
specific about what it means for it to work on other systems.


>Also, under Tiger the performance of retrieving the canonical path or the
>FileType seems to have degraded significantly from Panther. I have run
>performance tests where I check the canonical path or FileType in one test
>and do not test it in another. Previously, all numbers were virtually
>identical.

Without seeing the code of the test itself, it's difficult to comment.

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.