Modifier and Type | Class and Description |
---|---|
static class |
FS.Attributes
File attributes we typically care for.
|
static class |
FS.FSFactory
This class creates FS instances.
|
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(File f)
Determine if the file is executable (or not).
|
void |
createSymLink(File path,
String target)
Create a symbolic link
|
void |
delete(File f)
Delete a file.
|
static FS |
detect()
Auto-detect the appropriate file system abstraction.
|
static FS |
detect(Boolean cygwinUsed)
Auto-detect the appropriate file system abstraction, taking into account
the presence of a Cygwin installation on the system.
|
protected abstract 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
|
FS.Attributes |
getAttributes(File path) |
File |
gitPrefix() |
abstract 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.
|
boolean |
isHidden(File path) |
boolean |
isSymLink(File path) |
long |
lastModified(File f)
Get the last modified time of a file system object.
|
long |
length(File path)
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.
|
abstract FS |
newInstance() |
File |
normalize(File file)
Normalize the unicode path to composed form.
|
String |
normalize(String name)
Normalize the unicode path to composed form.
|
protected static String |
readPipe(File dir,
String[] command,
String encoding)
Execute a command and return a single line of output as a String
|
String |
readSymLink(File path)
Check if a file is a symbolic link and read it
|
File |
resolve(File dir,
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 ProcessBuilder |
runInShell(String cmd,
String[] args)
Initialize a ProcesssBuilder to run a command using the system shell.
|
protected static File |
searchPath(String path,
String... lookFor)
Searches the given path to see if it contains one of the given files.
|
abstract boolean |
setExecute(File f,
boolean canExec)
Set a file to be executable by the user.
|
FS |
setGitPrefix(File path)
Set the $prefix directory C Git uses.
|
void |
setHidden(File path,
boolean hidden)
Set the hidden attribute for file whose name starts with a period.
|
void |
setLastModified(File f,
long time)
Set the last modified time of a file system object.
|
FS |
setUserHome(File path)
Set the user's home directory location.
|
abstract 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.
|
File |
userHome()
Determine the user's home directory (location where preferences are).
|
protected 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(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 boolean supportsSymlinks()
public abstract boolean isCaseSensitive()
public abstract boolean canExecute(File f)
Not 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.
f
- abstract path to test.public abstract boolean setExecute(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 long lastModified(File f) throws IOException
f
- IOException
public void setLastModified(File f, long time) throws IOException
f
- time
- IOException
public long length(File path) throws IOException
path
- IOException
public void delete(File f) throws IOException
f
- IOException
- this may be a Java7 subclass with detailed informationpublic File resolve(File dir, 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 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(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 File userHomeImpl()
protected static File searchPath(String path, String... lookFor)
path
- List of paths to search separated by File.pathSeparatorlookFor
- Files to search for in the given pathprotected static String readPipe(File dir, String[] command, String encoding)
dir
- Working directory for the commandcommand
- as component arrayencoding
- public File gitPrefix()
protected abstract File discoverGitPrefix()
public FS setGitPrefix(File path)
path
- the directory. Null if C Git is not installed.this
public String readSymLink(File path) throws IOException
path
- IOException
public boolean isSymLink(File path) throws IOException
path
- IOException
public boolean exists(File path)
path
- public boolean isDirectory(File path)
path
- public boolean isFile(File path)
path
- public boolean isHidden(File path) throws IOException
path
- IOException
public void setHidden(File path, boolean hidden) throws IOException
path
- hidden
- IOException
public void createSymLink(File path, String target) throws IOException
path
- target
- IOException
public abstract ProcessBuilder runInShell(String cmd, 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.public FS.Attributes getAttributes(File path)
path
- public File normalize(File file)
file
- Copyright © 2014. All rights reserved.