public class FS_POSIX extends FS
FS.Attributes, FS.FSFactory| Modifier and Type | Field and Description |
|---|---|
protected static Boolean |
EXECUTE_FOR_GROUP |
protected static Boolean |
EXECUTE_FOR_OTHERS |
| Modifier | Constructor and Description |
|---|---|
protected |
FS_POSIX()
Default constructor
|
protected |
FS_POSIX(FS src)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canExecute(File f)
Determine if the file is executable (or not).
|
void |
createSymLink(File path,
String target)
Create a symbolic link
|
void |
delete(File path)
Delete a file.
|
protected File |
discoverGitPrefix() |
boolean |
exists(File path)
Tests if the path exists, in case of a symbolic link, true even if the
target does not exist
|
File |
findHook(Repository repository,
String hookName)
Tries to find a hook matching the given one in the given repository.
|
FS.Attributes |
getAttributes(File path) |
boolean |
isCaseSensitive()
Is this file system case sensitive
|
boolean |
isDirectory(File path)
Check if path is a directory.
|
boolean |
isFile(File path)
Examine if path represents a regular file.
|
protected static Boolean |
isGranted(PosixFilePermission p,
String umask)
Derives requested permission from given octal umask value as defined e.g.
|
boolean |
isHidden(File path) |
boolean |
isSymLink(File path) |
long |
lastModified(File path)
Get the last modified time of a file system object.
|
long |
length(File f)
Get the length of a file or link, If the OS/JRE supports symbolic links
it's the length of the link, else the length of the target.
|
FS |
newInstance() |
File |
normalize(File file)
Normalize the unicode path to composed form.
|
String |
normalize(String name)
Normalize the unicode path to composed form.
|
String |
readSymLink(File path)
Check if a file is a symbolic link and read it
|
protected static String |
readUmask() |
boolean |
retryFailedLockFileCommit()
Does this file system have problems with atomic renames?
|
ProcessResult |
runHookIfPresent(Repository repository,
String hookName,
String[] args,
PrintStream outRedirect,
PrintStream errRedirect,
String stdinArgs)
Checks whether the given hook is defined for the given repository, then
runs it with the given arguments.
|
ProcessBuilder |
runInShell(String cmd,
String[] args)
Initialize a ProcesssBuilder to run a command using the system shell.
|
boolean |
setExecute(File f,
boolean canExecute)
Set a file to be executable by the user.
|
void |
setHidden(File path,
boolean hidden)
Set the hidden attribute for file whose name starts with a period.
|
void |
setLastModified(File path,
long time)
Set the last modified time of a file system object.
|
boolean |
supportsExecute()
Does this operating system and JRE support the execute flag on files?
|
boolean |
supportsSymlinks()
Does this operating system and JRE supports symbolic links.
|
detect, detect, gitPrefix, internalRunHookIfPresent, readPipe, relativize, resolve, runHookIfPresent, runProcess, searchPath, setGitPrefix, setUserHome, userHome, userHomeImplprotected static final Boolean EXECUTE_FOR_OTHERS
protected static final Boolean EXECUTE_FOR_GROUP
protected FS_POSIX()
protected FS_POSIX(FS src)
src - FS to copy some settings frompublic FS newInstance()
newInstance in class FSprotected static Boolean isGranted(PosixFilePermission p, String umask)
The umask expected here must consist of 3 or 4 digits. Last three digits are significant here because they represent file permissions granted to the "owner", "group" and "others" (in this order).
Each single digit from the umask represents 3 bits of the mask standing for "read, write, execute" permissions (in this order).
The possible umask values table:
Value : Bits:Abbr.: Permission
0 : 000 :rwx : read, write and execute
1 : 001 :rw : read and write
2 : 010 :rx : read and execute
3 : 011 :r : read only
4 : 100 :wx : write and execute
5 : 101 :w : write only
6 : 110 :x : execute only
7 : 111 : : no permissions
Note, that umask value is used to "mask" the requested permissions on file creation by combining the requested permission bit with the negated value of the umask bit.
Simply speaking, if a bit is not set in the umask, then the appropriate right will be granted if requested. If a bit is set in the umask value, then the appropriate permission will be not granted.
Example:
p - non null permissionumask - octal umask value represented by at least three digits. The
digits (read from the end to beginning of the umask) represent
permissions for "others", "group" and "owner".protected static String readUmask()
protected File discoverGitPrefix()
discoverGitPrefix in class FSpublic boolean isCaseSensitive()
FSisCaseSensitive in class FSpublic boolean supportsExecute()
FSsupportsExecute in class FSpublic boolean canExecute(File f)
FSNot all platforms and JREs support executable flags on files. If the feature is unsupported this method will always return false.
If the platform supports symbolic links and f is a symbolic link
this method returns false, rather than the state of the executable flags
on the target file.
canExecute in class FSf - abstract path to test.public boolean setExecute(File f, boolean canExecute)
FSNot all platforms and JREs support executable flags on files. If the feature is unsupported this method will always return false and no changes will be made to the file specified.
setExecute in class FSf - path to modify the executable status of.canExecute - true to enable execution; false to disable it.public ProcessBuilder runInShell(String cmd, String[] args)
FSrunInShell in class FScmd - command to execute. This string should originate from the
end-user, and thus is platform specific.args - arguments to pass to command. These should be protected from
shell evaluation.public ProcessResult runHookIfPresent(Repository repository, String hookName, String[] args, PrintStream outRedirect, PrintStream errRedirect, String stdinArgs) throws JGitInternalException
FSrunHookIfPresent in class FSrepository - The repository for which a hook should be run.hookName - The name of the hook to be executed.args - Arguments to pass to this hook. Cannot be null,
but can be an empty array.outRedirect - A print stream on which to redirect the hook's stdout. Can be
null, in which case the hook's standard output
will be lost.errRedirect - A print stream on which to redirect the hook's stderr. Can be
null, in which case the hook's standard error
will be lost.stdinArgs - A string to pass on to the standard input of the hook. May be
null.JGitInternalException - if we fail to run the hook somehow. Causes may include an
interrupted process or I/O errors.public boolean retryFailedLockFileCommit()
FSretryFailedLockFileCommit in class FSpublic boolean supportsSymlinks()
FSsupportsSymlinks in class FSpublic boolean isSymLink(File path) throws IOException
isSymLink in class FSIOExceptionpublic long lastModified(File path) throws IOException
FSlastModified in class FSIOExceptionpublic void setLastModified(File path, long time) throws IOException
FSsetLastModified in class FSIOExceptionpublic void delete(File path) throws IOException
FSdelete in class FSIOException - this may be a Java7 subclass with detailed informationpublic long length(File f) throws IOException
FSlength in class FSIOExceptionpublic boolean exists(File path)
FSpublic boolean isDirectory(File path)
FSisDirectory in class FSpublic boolean isFile(File path)
FSpublic boolean isHidden(File path) throws IOException
isHidden in class FSIOExceptionpublic void setHidden(File path, boolean hidden) throws IOException
FSsetHidden in class FSIOExceptionpublic String readSymLink(File path) throws IOException
FSreadSymLink in class FSIOExceptionpublic void createSymLink(File path, String target) throws IOException
FScreateSymLink in class FSIOExceptionpublic FS.Attributes getAttributes(File path)
getAttributes in class FSpublic File normalize(File file)
FSpublic String normalize(String name)
FSpublic File findHook(Repository repository, String hookName)
FSCopyright © 2015. All rights reserved.