public abstract class FS
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static FS |
DETECTED
The auto-detected implementation selected for this operating system and JRE.
|
Modifier | Constructor and Description |
---|---|
protected |
FS()
Constructs a file system abstraction.
|
protected |
FS(FS src)
Initialize this FS using another's current settings.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
canExecute(java.io.File f)
Determine if the file is executable (or not).
|
static FS |
detect()
Auto-detect the appropriate file system abstraction.
|
static FS |
detect(java.lang.Boolean cygwinUsed)
Auto-detect the appropriate file system abstraction, taking into account
the presence of a Cygwin installation on the system.
|
protected abstract java.io.File |
discoverGitPrefix() |
java.io.File |
gitPrefix() |
abstract FS |
newInstance() |
protected static java.lang.String |
readPipe(java.io.File dir,
java.lang.String[] command,
java.lang.String encoding)
Execute a command and return a single line of output as a String
|
java.io.File |
resolve(java.io.File dir,
java.lang.String name)
Resolve this file to its actual path name that the JRE can use.
|
abstract boolean |
retryFailedLockFileCommit()
Does this file system have problems with atomic renames?
|
abstract java.lang.ProcessBuilder |
runInShell(java.lang.String cmd,
java.lang.String[] args)
Initialize a ProcesssBuilder to run a command using the system shell.
|
abstract boolean |
setExecute(java.io.File f,
boolean canExec)
Set a file to be executable by the user.
|
FS |
setGitPrefix(java.io.File path)
Set the $prefix directory C Git uses.
|
FS |
setUserHome(java.io.File path)
Set the user's home directory location.
|
abstract boolean |
supportsExecute()
Does this operating system and JRE support the execute flag on files?
|
java.io.File |
userHome()
Determine the user's home directory (location where preferences are).
|
protected java.io.File |
userHomeImpl()
Determine the user's home directory (location where preferences are).
|
public static final FS DETECTED
protected FS()
protected FS(FS src)
src
- the source FS to copy from.public static FS detect()
public static FS detect(java.lang.Boolean cygwinUsed)
cygwinUsed
- Boolean.TRUE
to assume that Cygwin is used in
combination with jgitBoolean.FALSE
to assume that Cygwin is
not used with jgitnull
to auto-detect whether a Cygwin
installation is present on the system and in this case assume
that Cygwin is usedpublic abstract FS newInstance()
public abstract boolean supportsExecute()
public abstract boolean canExecute(java.io.File f)
Not all platforms and JREs support executable flags on files. If the feature is unsupported this method will always return false.
f
- abstract path to test.public abstract boolean setExecute(java.io.File f, boolean canExec)
Not 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.
f
- path to modify the executable status of.canExec
- true to enable execution; false to disable it.public java.io.File resolve(java.io.File dir, java.lang.String name)
This method can be relatively expensive. Computing a translation may require forking an external process per path name translated. Callers should try to minimize the number of translations necessary by caching the results.
Not all platforms and JREs require path name translation. Currently only Cygwin on Win32 require translation for Cygwin based paths.
dir
- directory relative to which the path name is.name
- path name to translate.new File(dir,name)
if this
platform does not require path name translation.public java.io.File userHome()
This method can be expensive on the first invocation if path name translation is required. Subsequent invocations return a cached result.
Not all platforms and JREs require path name translation. Currently only Cygwin on Win32 requires translation of the Cygwin HOME directory.
public FS setUserHome(java.io.File path)
path
- the location of the user's preferences; null if there is no
home directory for the current user.this
.public abstract boolean retryFailedLockFileCommit()
protected java.io.File userHomeImpl()
protected static java.lang.String readPipe(java.io.File dir, java.lang.String[] command, java.lang.String encoding)
dir
- Working directory for the commandcommand
- as component arrayencoding
- public java.io.File gitPrefix()
protected abstract java.io.File discoverGitPrefix()
public FS setGitPrefix(java.io.File path)
path
- the directory. Null if C Git is not installed.this
public abstract java.lang.ProcessBuilder runInShell(java.lang.String cmd, java.lang.String[] args)
cmd
- 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.Copyright © 2012. All Rights Reserved.