com.perforce.p4java.impl.mapbased.rpc.sys.helper
Class SymbolicLinkHelper

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

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).


Field Summary
static String COPY_OPTION_CLASS_NAME
           
static String FILE_ATTRIBUTE_CLASS_NAME
           
static String FILE_SYSTEM_CLASS_NAME
           
static String FILE_SYSTEM_GET_PATH_METHOD_NAME
           
static String FILE_SYSTEMS_CLASS_NAME
           
static String FILE_SYSTEMS_GET_DEFAULT_METHOD_NAME
           
static String FILE_TIME_CLASS_NAME
           
static String FILE_TIME_PATTERN
           
static String FILE_TIME_TO_MILLIS_METHOD_NAME
           
static String FILES_CLASS_NAME
           
static String FILES_CREATE_SYMBOLIC_LINK_METHOD_NAME
           
static String FILES_EXISTS_METHOD_NAME
           
static String FILES_GET_LAST_MODIFIED_TIME_METHOD_NAME
           
static String FILES_IS_SYMBOLIC_LINK_METHOD_NAME
           
static String FILES_MOVE_METHOD_NAME
           
static String FILES_READ_SYMBOLIC_LINK_METHOD_NAME
           
static String LINK_OPTION_CLASS_NAME
           
static String PATH_CLASS_NAME
           
 
Constructor Summary
SymbolicLinkHelper()
           
 
Method Summary
static String createSymbolicLink(String link, String target)
          Creates a symbolic link to a target.
static boolean exists(String path)
          Tests whether a file is a symbolic link.
static long getLastModifiedTime(String link)
          Gets the last modified time for a symbolic link.
static boolean isSymbolicLink(String path)
          Tests whether a file is a symbolic link.
static boolean isSymbolicLinkCapable()
          Checks if is symbolic link capable.
static String move(String source, String target)
          Creates a symbolic link to a target.
static String readSymbolicLink(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
 

Field Detail

FILE_TIME_PATTERN

public static final String FILE_TIME_PATTERN
See Also:
Constant Field Values

FILE_SYSTEMS_CLASS_NAME

public static final String FILE_SYSTEMS_CLASS_NAME
See Also:
Constant Field Values

FILE_SYSTEM_CLASS_NAME

public static final String FILE_SYSTEM_CLASS_NAME
See Also:
Constant Field Values

PATH_CLASS_NAME

public static final String PATH_CLASS_NAME
See Also:
Constant Field Values

FILES_CLASS_NAME

public static final String FILES_CLASS_NAME
See Also:
Constant Field Values

FILE_ATTRIBUTE_CLASS_NAME

public static final String FILE_ATTRIBUTE_CLASS_NAME
See Also:
Constant Field Values

LINK_OPTION_CLASS_NAME

public static final String LINK_OPTION_CLASS_NAME
See Also:
Constant Field Values

FILE_TIME_CLASS_NAME

public static final String FILE_TIME_CLASS_NAME
See Also:
Constant Field Values

COPY_OPTION_CLASS_NAME

public static final String COPY_OPTION_CLASS_NAME
See Also:
Constant Field Values

FILE_SYSTEMS_GET_DEFAULT_METHOD_NAME

public static final String FILE_SYSTEMS_GET_DEFAULT_METHOD_NAME
See Also:
Constant Field Values

FILE_SYSTEM_GET_PATH_METHOD_NAME

public static final String FILE_SYSTEM_GET_PATH_METHOD_NAME
See Also:
Constant Field Values

FILES_IS_SYMBOLIC_LINK_METHOD_NAME

public static final String FILES_IS_SYMBOLIC_LINK_METHOD_NAME
See Also:
Constant Field Values

FILES_EXISTS_METHOD_NAME

public static final String FILES_EXISTS_METHOD_NAME
See Also:
Constant Field Values

FILES_CREATE_SYMBOLIC_LINK_METHOD_NAME

public static final String FILES_CREATE_SYMBOLIC_LINK_METHOD_NAME
See Also:
Constant Field Values

FILES_READ_SYMBOLIC_LINK_METHOD_NAME

public static final String FILES_READ_SYMBOLIC_LINK_METHOD_NAME
See Also:
Constant Field Values

FILES_GET_LAST_MODIFIED_TIME_METHOD_NAME

public static final String FILES_GET_LAST_MODIFIED_TIME_METHOD_NAME
See Also:
Constant Field Values

FILE_TIME_TO_MILLIS_METHOD_NAME

public static final String FILE_TIME_TO_MILLIS_METHOD_NAME
See Also:
Constant Field Values

FILES_MOVE_METHOD_NAME

public static final String FILES_MOVE_METHOD_NAME
See Also:
Constant Field Values
Constructor Detail

SymbolicLinkHelper

public SymbolicLinkHelper()
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(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.

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

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


Copyright © 2015 Perforce Software. All Rights Reserved.