Class MacAlias

java.lang.Object
slash.common.io.MacAlias
All Implemented Interfaces:
ResolvableLink

public class MacAlias extends Object implements ResolvableLink
Represents a macOS Finder alias (a regular file carrying bookmark data, the counterpart to a Windows WindowsShortcut). Detection sniffs the "book" bookmark-data magic; resolution to the target path is delegated to osascript/Finder, since the bookmark format is not stably parseable.
Author:
Christian Pesch
  • Constructor Details

  • Method Details

    • isPotentialValidAlias

      public static boolean isPotentialValidAlias(File file) throws IOException
      Provides a quick test to see if this could be a valid macOS alias. Instantiating a MacAlias spawns an osascript process, so any code looping over several files should first check this.
      Parameters:
      file - the potential alias
      Returns:
      true if this is a macOS running a file that carries the alias magic, false otherwise
      Throws:
      IOException - if an IOException is thrown while reading from the file
    • getRealFilename

      public String getRealFilename()
      Specified by:
      getRealFilename in interface ResolvableLink
      Returns:
      the name of the filesystem object pointed to by this alias
    • isDirectory

      public boolean isDirectory()
      Specified by:
      isDirectory in interface ResolvableLink
      Returns:
      true if the alias points to a directory, false otherwise
    • isFile

      public boolean isFile()
      Specified by:
      isFile in interface ResolvableLink
      Returns:
      true if the link points to a file