|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ISystemFileCommandsHelper
An interface that specifies a set of useful file-level functions (such as recognizing a symbolic link or setting writable or executable bits) that are not always implemented by vanilla Java installations, and that can be used by P4Java to implement these file operations when the surrounding JVm or JDK does not do a good job.
Java native P4Java implementations have to cope with the fact that most vanilla JDK 5 implementations have poor or even non-existent support for file-level metadata manipulations; JDK 6 is not much better, but does allow you to set a file writable and executable (albeit without honoring the Unix umask settings). In order to allow JDK 5 installations to use the P4Java NIO / RPC implementations, this interface is provided in conjunction with the server factory's setRpcFileSystemHelper method to allow users to specify a helper class (or classes) that implement these functions using native libraries or external functions (such as Eclipse's file helpers). Note that this class can be safely ignored if you are using the p4 command line protocol implementation, and can typically be ignored with all protocol implementations if you are using JDK 6 or later.
Methods here concentrate on mundane file mode changes and metadata, mostly, but may be added to as time goes by. The semantics of the individual methods below are intended to be the same as those for the corresponding methods defined on JDK 6's File class (where they exist), with broad interpretations allowed.
Note that all methods defined below must be implemented in a thread-safe way and not cause undue thread blocking, as they're called at crucial stages of the underlying RPC implementation. Note also that the supplied SystemFileCommands implementation must work safely even if it's just instantiated once per P4Java installation for all requests (i.e. it must work as a singleton).
Method Summary | |
---|---|
boolean |
canExecute(String fileName)
Return true iff the file exists and is executable. |
boolean |
isSymlink(String fileName)
Return true iff the file exists and is a symbolic link. |
boolean |
setExecutable(String fileName,
boolean executable,
boolean ownerOnly)
Set the file's permissions to allow or disallow it to be executed. |
boolean |
setOwnerReadOnly(String fileName)
Set the file's read permissions only allow reading by owner. |
boolean |
setReadable(String fileName,
boolean readable,
boolean ownerOnly)
Set the file's permissions to allow or disallow reading from it. |
boolean |
setWritable(String fileName,
boolean writable)
Set the file's permissions to allow or disallow writing to it. |
Method Detail |
---|
boolean setWritable(String fileName, boolean writable)
fileName
- non-null path or name of the target file.writable
- if true, allow the file to be written to; if false,
set the file read-only (or, more accurately, not writable).
boolean setReadable(String fileName, boolean readable, boolean ownerOnly)
fileName
- non-null path or name of the target file.
set the file read-only.readable
- if true, allow the file to be read; if false,
set the file to not be readableownerOnly
- true to only set the read-only bit for the owner
boolean setOwnerReadOnly(String fileName)
fileName
- non-null path or name of the target file.
set the file read-only.
boolean setExecutable(String fileName, boolean executable, boolean ownerOnly)
fileName
- non-null path or name of the target file.executable
- if true, allow the file to be executed; if false,
set the file not executable.ownerOnly
- true to only set the executable bit for the owner
boolean canExecute(String fileName)
fileName
- non-null path or name of the target file.
boolean isSymlink(String fileName)
This method is guaranteed to only be called when we suspect a specific file may be a symbolic link (i.e. we've exhausted other possibilities) and it is safe for this method to return false if it can't implement the associated plumbing or it simply can't tell whether the file is a symlink or not.
fileName
- non-null path or name of the target file.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |