本文整理了Java中org.eclipse.jgit.util.FS.userHome()
方法的一些代码示例,展示了FS.userHome()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FS.userHome()
方法的具体详情如下:
包路径:org.eclipse.jgit.util.FS
类名称:FS
方法名:userHome
[英]Determine the user's home directory (location where preferences are).
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.
[中]确定用户的主目录(首选项所在的位置)。
如果需要进行路径名转换,则在第一次调用时,此方法可能会很昂贵。后续调用将返回缓存的结果。
并非所有平台和JRE都需要路径名转换。目前,Win32上只有Cygwin需要转换Cygwin主目录。
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private static File getDefaultFile() {
File home = FS.DETECTED.userHome();
File netrc = new File(home, ".netrc"); //$NON-NLS-1$
if (netrc.exists())
return netrc;
netrc = new File(home, "_netrc"); //$NON-NLS-1$
if (netrc.exists())
return netrc;
return null;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
@Override
public FileBasedConfig openUserConfig(Config parent, FS fs) {
final File home = fs.userHome();
return new FileBasedConfig(parent, new File(home, ".gitconfig"), fs); //$NON-NLS-1$
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private static void knownHosts(JSch sch, FS fs) throws JSchException {
final File home = fs.userHome();
if (home == null)
return;
final File known_hosts = new File(new File(home, ".ssh"), "known_hosts"); //$NON-NLS-1$ //$NON-NLS-2$
try (FileInputStream in = new FileInputStream(known_hosts)) {
sch.setKnownHosts(in);
} catch (FileNotFoundException none) {
// Oh well. They don't have a known hosts in home.
} catch (IOException err) {
// Oh well. They don't have a known hosts in home.
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Obtain the user's configuration data.
* <p>
* The configuration file is always returned to the caller, even if no file
* exists in the user's home directory at the time the call was made. Lookup
* requests are cached and are automatically updated if the user modifies
* the configuration file since the last time it was cached.
*
* @param fs
* the file system abstraction which will be necessary to
* perform certain file system operations.
* @return a caching reader of the user's configuration file.
*/
public static OpenSshConfig get(FS fs) {
File home = fs.userHome();
if (home == null)
home = new File(".").getAbsoluteFile(); //$NON-NLS-1$
final File config = new File(new File(home, SshConstants.SSH_DIR),
SshConstants.CONFIG);
return new OpenSshConfig(home, config);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private static void identities(JSch sch, FS fs) {
final File home = fs.userHome();
if (home == null)
return;
final File sshdir = new File(home, ".ssh"); //$NON-NLS-1$
if (sshdir.isDirectory()) {
loadIdentity(sch, new File(sshdir, "identity")); //$NON-NLS-1$
loadIdentity(sch, new File(sshdir, "id_rsa")); //$NON-NLS-1$
loadIdentity(sch, new File(sshdir, "id_dsa")); //$NON-NLS-1$
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* {@inheritDoc}
*
* @since 4.10
*/
@Override
protected byte[] readIncludedConfig(String relPath)
throws ConfigInvalidException {
final File file;
if (relPath.startsWith("~/")) { //$NON-NLS-1$
file = fs.resolve(fs.userHome(), relPath.substring(2));
} else {
file = fs.resolve(configFile.getParentFile(), relPath);
}
if (!file.exists()) {
return null;
}
try {
return IO.readFully(file);
} catch (IOException ioe) {
throw new ConfigInvalidException(MessageFormat
.format(JGitText.get().cannotReadFile, relPath), ioe);
}
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private Properties loadProperties() throws NotSupportedException {
if (local.getDirectory() != null) {
File propsFile = new File(local.getDirectory(), uri.getUser());
if (propsFile.isFile())
return loadPropertiesFile(propsFile);
}
File propsFile = new File(local.getFS().userHome(), uri.getUser());
if (propsFile.isFile())
return loadPropertiesFile(propsFile);
Properties props = new Properties();
String user = uri.getUser();
String pass = uri.getPass();
if (user != null && pass != null) {
props.setProperty("accesskey", user); //$NON-NLS-1$
props.setProperty("secretkey", pass); //$NON-NLS-1$
} else
throw new NotSupportedException(MessageFormat.format(
JGitText.get().cannotReadFile, propsFile));
return props;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Load the attributes node
*
* @return the attributes node
* @throws java.io.IOException
*/
public AttributesNode load() throws IOException {
AttributesNode r = new AttributesNode();
FS fs = repository.getFS();
String path = repository.getConfig().get(CoreConfig.KEY)
.getAttributesFile();
if (path != null) {
File attributesFile;
if (path.startsWith("~/")) { //$NON-NLS-1$
attributesFile = fs.resolve(fs.userHome(),
path.substring(2));
} else {
attributesFile = fs.resolve(null, path);
}
FileRepository.AttributesNodeProviderImpl.loadRulesFromFile(r, attributesFile);
}
return r.getRules().isEmpty() ? null : r;
}
}
代码示例来源:origin: diffplug/spotless
FS fs = FS.detect();
if (globalAttributesPath.startsWith("~/")) { //$NON-NLS-1$
globalAttributesFile = fs.resolve(fs.userHome(), globalAttributesPath.substring(2));
} else {
globalAttributesFile = fs.resolve(null, globalAttributesPath);
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
@Override
IgnoreNode load() throws IOException {
IgnoreNode r;
if (entry != null) {
r = super.load();
if (r == null)
r = new IgnoreNode();
} else {
r = new IgnoreNode();
}
FS fs = repository.getFS();
String path = repository.getConfig().get(CoreConfig.KEY)
.getExcludesFile();
if (path != null) {
File excludesfile;
if (path.startsWith("~/")) //$NON-NLS-1$
excludesfile = fs.resolve(fs.userHome(), path.substring(2));
else
excludesfile = fs.resolve(null, path);
loadRulesFromFile(r, excludesfile);
}
File exclude = fs.resolve(repository.getDirectory(),
Constants.INFO_EXCLUDE);
loadRulesFromFile(r, exclude);
return r.getRules().isEmpty() ? null : r;
}
代码示例来源:origin: kiegroup/droolsjbpm-tools
private static String getDefaultDefaultRepositoryDir() {
return new File(FS.DETECTED.userHome(), "git").getPath(); //$NON-NLS-1$
}
代码示例来源:origin: berlam/github-bucket
private static File getDefaultFile() {
File home = FS.DETECTED.userHome();
File netrc = new File(home, ".netrc"); //$NON-NLS-1$
if (netrc.exists())
return netrc;
netrc = new File(home, "_netrc"); //$NON-NLS-1$
if (netrc.exists())
return netrc;
return null;
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
private static File getDefaultFile() {
File home = FS.DETECTED.userHome();
File netrc = new File(home, ".netrc"); //$NON-NLS-1$
if (netrc.exists())
return netrc;
netrc = new File(home, "_netrc"); //$NON-NLS-1$
if (netrc.exists())
return netrc;
return null;
}
代码示例来源:origin: berlam/github-bucket
@Override
public FileBasedConfig openUserConfig(Config parent, FS fs) {
final File home = fs.userHome();
return new FileBasedConfig(parent, new File(home, ".gitconfig"), fs); //$NON-NLS-1$
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
public FileBasedConfig openUserConfig(Config parent, FS fs) {
final File home = fs.userHome();
return new FileBasedConfig(parent, new File(home, ".gitconfig"), fs); //$NON-NLS-1$
}
代码示例来源:origin: com.g2forge.gearbox/gb-git
protected static void knownHosts(final JSch jsch, FS fs) throws JSchException {
final File home = fs.userHome();
if (home == null) return;
final Path knownHosts = home.toPath().resolve(HSSH.SSHDIR).resolve(HSSH.KNOWN_HOSTS);
try {
try (final InputStream in = Files.newInputStream(knownHosts)) {
jsch.setKnownHosts(in);
}
} catch (IOException exception) {
// No known hosts file, no real problem
}
}
代码示例来源:origin: berlam/github-bucket
private static void identities(JSch sch, FS fs) {
final File home = fs.userHome();
if (home == null)
return;
final File sshdir = new File(home, ".ssh"); //$NON-NLS-1$
if (sshdir.isDirectory()) {
loadIdentity(sch, new File(sshdir, "identity")); //$NON-NLS-1$
loadIdentity(sch, new File(sshdir, "id_rsa")); //$NON-NLS-1$
loadIdentity(sch, new File(sshdir, "id_dsa")); //$NON-NLS-1$
}
}
代码示例来源:origin: com.atlassian.maven.plugins/maven-jgitflow-plugin
private void identities(final JSch sch, FS fs)
{
final File home = fs.userHome();
if (home == null)
{ return; }
final File sshdir = new File(home, ".ssh");
if (sshdir.isDirectory())
{
loadIdentity(sch, new File(sshdir, "identity"));
loadIdentity(sch, new File(sshdir, "id_rsa"));
loadIdentity(sch, new File(sshdir, "id_dsa"));
}
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
private static void identities(final JSch sch, FS fs) {
final File home = fs.userHome();
if (home == null)
return;
final File sshdir = new File(home, ".ssh"); //$NON-NLS-1$
if (sshdir.isDirectory()) {
loadIdentity(sch, new File(sshdir, "identity")); //$NON-NLS-1$
loadIdentity(sch, new File(sshdir, "id_rsa")); //$NON-NLS-1$
loadIdentity(sch, new File(sshdir, "id_dsa")); //$NON-NLS-1$
}
}
代码示例来源:origin: liveoak-io/liveoak
@Override
protected JSch getJSch(OpenSshConfig.Host hc, FS fs) throws JSchException {
JSch jsch = super.getJSch(hc, fs);
if (StringUtils.hasValue(passphrase)) {
// If passphrase is set, add it to identity
File sshDir = new File(fs.userHome(), ".ssh");
if (sshDir.isDirectory()) {
updateIdentity(jsch, new File(sshDir, "identity"));
updateIdentity(jsch, new File(sshDir, "id_rsa"));
updateIdentity(jsch, new File(sshDir, "id_dsa"));
}
}
return jsch;
}
内容来源于网络,如有侵权,请联系作者删除!