Class SymbolicLinkHelper
java.lang.Object
com.perforce.p4java.impl.mapbased.rpc.sys.helper.SymbolicLinkHelper
- All Implemented Interfaces:
ISystemFileCommandsHelper
- Direct Known Subclasses:
RpcSystemFileCommandsHelper,WindowsRpcSystemFileCommandsHelper
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateSymbolicLink(String link, String target) Creates a symbolic link to a target.static booleanTests whether a file is a symbolic link.static longgetLastModifiedTime(String link) Gets the last modified time for a symbolic link.static booleanisSymbolicLink(String path) Tests whether a file is a symbolic link.static booleanChecks if is symbolic link capable.static StringCreates a symbolic link to a target.static StringreadSymbolicLink(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, waitMethods inherited from interface com.perforce.p4java.impl.generic.sys.ISystemFileCommandsHelper
canExecute, isSymlink, setExecutable, setOwnerReadOnly, setReadable, setWritable
-
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
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
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
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
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
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
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
-