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 java.lang.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 Summary
Constructors Constructor Description SymbolicLinkHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
createSymbolicLink(java.lang.String link, java.lang.String target)
Creates a symbolic link to a target.static boolean
exists(java.lang.String path)
Tests whether a file is a symbolic link.static long
getLastModifiedTime(java.lang.String link)
Gets the last modified time for a symbolic link.static boolean
isSymbolicLink(java.lang.String path)
Tests whether a file is a symbolic link.static boolean
isSymbolicLinkCapable()
Checks if is symbolic link capable.static java.lang.String
move(java.lang.String source, java.lang.String target)
Creates a symbolic link to a target.static java.lang.String
readSymbolicLink(java.lang.String link)
Reads the target path of a symbolic link.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.perforce.p4java.impl.generic.sys.ISystemFileCommandsHelper
canExecute, isSymlink, setExecutable, setOwnerReadOnly, setReadable, setWritable
-
-
-
-
Method Detail
-
isSymbolicLinkCapable
public static boolean isSymbolicLinkCapable()
Checks if is symbolic link capable.- Returns:
- true, if is symbolic link capable
-
isSymbolicLink
public static boolean isSymbolicLink(java.lang.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 java.lang.String readSymbolicLink(java.lang.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(java.lang.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(java.lang.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 java.lang.String move(java.lang.String source, java.lang.String target)
Creates a symbolic link to a target.- Parameters:
source
- the path of the path to the file to movetarget
- the path to the target file- Returns:
- the path to the target file
-
createSymbolicLink
public static java.lang.String createSymbolicLink(java.lang.String link, java.lang.String target)
Creates a symbolic link to a target.- Parameters:
link
- the path of the symbolic link to createtarget
- the target of the symbolic link- Returns:
- path the path to the symbolic link
-
-