|
|
|
|
|
|
|
|
|
|
|
|
|
|
private volatile Holder<File> userHome; |
|
|
private volatile Holder<File> userHome; |
|
|
|
|
|
|
|
|
private volatile Holder<File> gitPrefix; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructs a file system abstraction. |
|
|
* Constructs a file system abstraction. |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
*/ |
|
|
*/ |
|
|
protected FS(FS src) { |
|
|
protected FS(FS src) { |
|
|
userHome = src.userHome; |
|
|
userHome = src.userHome; |
|
|
gitPrefix = src.gitPrefix; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** @return a new instance of the same type of FS. */ |
|
|
/** @return a new instance of the same type of FS. */ |
|
|
|
|
|
|
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** @return the $prefix directory C Git would use. */ |
|
|
|
|
|
public File gitPrefix() { |
|
|
|
|
|
Holder<File> p = gitPrefix; |
|
|
|
|
|
if (p == null) { |
|
|
|
|
|
String overrideGitPrefix = SystemReader.getInstance().getProperty( |
|
|
|
|
|
"jgit.gitprefix"); //$NON-NLS-1$ |
|
|
|
|
|
if (overrideGitPrefix != null) |
|
|
|
|
|
p = new Holder<File>(new File(overrideGitPrefix)); |
|
|
|
|
|
else |
|
|
|
|
|
p = new Holder<File>(discoverGitPrefix()); |
|
|
|
|
|
gitPrefix = p; |
|
|
|
|
|
} |
|
|
|
|
|
return p.value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @return the path to the Git executable. |
|
|
* @return the path to the Git executable. |
|
|
* @since 4.0 |
|
|
* @since 4.0 |
|
|
|
|
|
|
|
|
return new File(w); |
|
|
return new File(w); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** @return the $prefix directory C Git would use. */ |
|
|
|
|
|
protected File discoverGitPrefix() { |
|
|
|
|
|
return resolveGrandparentFile(discoverGitExe()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param grandchild |
|
|
* @param grandchild |
|
|
* @return the parent directory of this file's parent directory or |
|
|
* @return the parent directory of this file's parent directory or |
|
|
|
|
|
|
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Set the $prefix directory C Git uses. |
|
|
|
|
|
* |
|
|
|
|
|
* @param path |
|
|
|
|
|
* the directory. Null if C Git is not installed. |
|
|
|
|
|
* @return {@code this} |
|
|
|
|
|
*/ |
|
|
|
|
|
public FS setGitPrefix(File path) { |
|
|
|
|
|
gitPrefix = new Holder<File>(path); |
|
|
|
|
|
return this; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Check if a file is a symbolic link and read it |
|
|
* Check if a file is a symbolic link and read it |
|
|
* |
|
|
* |