Class SymbolicLinkHelper

java.lang.Object
com.perforce.p4java.impl.mapbased.rpc.sys.helper.SymbolicLinkHelper
All Implemented Interfaces:
ISystemFileCommandsHelper
Direct Known Subclasses:
RpcSystemFileCommandsHelper, WindowsRpcSystemFileCommandsHelper

public abstract class SymbolicLinkHelper extends Object implements ISystemFileCommandsHelper
Abstract helper class for dynamically determine and use symbolic link support in the Java NIO package (JDK 7 or above).

Note that for Windows systems, hard links are available as of Windows 2000, and symbolic links as of Windows Vista. Therefore, for symbolic link support the Windows version needs to be Windows Vista or above.

The creation of symbolic links during the sync operation requires the link path and target path to be valid on the operating platform.

If a file changes its type to a symlink in Perforce, the content (data) of the file will be used as the link target. In this case, most likely the content (string representation) would not be a valid path.

As of this writing, the Perforce server and client treat hard links as normal files/dirs (Perforce cannot tell the difference).

  • Constructor Details

    • SymbolicLinkHelper

      public SymbolicLinkHelper()
  • Method Details

    • isSymbolicLinkCapable

      public static boolean isSymbolicLinkCapable()
      Checks if is symbolic link capable.
      Returns:
      true, if is symbolic link capable
    • isSymbolicLink

      public static boolean isSymbolicLink(String path)
      Tests whether a file is a symbolic link.
      Parameters:
      path - the path of the symbolic link
      Returns:
      true if the file is a symbolic link; false if the file does not exist, is not a symbolic link, or it cannot be determined if the file is a symbolic link or not.
    • readSymbolicLink

      public static String readSymbolicLink(String link)
      Reads the target path of a symbolic link.
      Parameters:
      link - the path to the symbolic link
      Returns:
      path the target path of the symbolic link
    • getLastModifiedTime

      public static long getLastModifiedTime(String link)
      Gets the last modified time for a symbolic link. Note: symbolic links are not followed (NOFOLLOW_LINKS LinkOption)
      Parameters:
      link - the path to the symbolic link
      Returns:
      last modified time of the symbolic link
    • exists

      public static boolean exists(String path)
      Tests whether a file is a symbolic link. Note: symbolic links are not followed (NOFOLLOW_LINKS LinkOption).
      Parameters:
      path - the path of the file or symbolic link
      Returns:
      true if the file or symbolic link exists; false if it does not exist, or it cannot be determined.
    • move

      public static String move(String source, String target)
      Creates a symbolic link to a target.
      Parameters:
      source - the path of the path to the file to move
      target - the path to the target file
      Returns:
      the path to the target file
    • createSymbolicLink

      public static String createSymbolicLink(String link, String target)
      Creates a symbolic link to a target.
      Parameters:
      link - the path of the symbolic link to create
      target - the target of the symbolic link
      Returns:
      path the path to the symbolic link