本文整理了Java中com.sun.enterprise.util.io.FileUtils.safeGetCanonicalPath()
方法的一些代码示例,展示了FileUtils.safeGetCanonicalPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.safeGetCanonicalPath()
方法的具体详情如下:
包路径:com.sun.enterprise.util.io.FileUtils
类名称:FileUtils
方法名:safeGetCanonicalPath
暂无
代码示例来源:origin: org.glassfish.main.admin/backup
private void setProps(BackupRequest request) {
props.setProperty(Constants.PROPS_USER_NAME,
System.getProperty(Constants.PROPS_USER_NAME));
props.setProperty(Constants.PROPS_TIMESTAMP_MSEC,
"" + request.timestamp);
props.setProperty(Constants.PROPS_DOMAINS_DIR,
FileUtils.safeGetCanonicalPath(request.domainsDir));
props.setProperty(Constants.PROPS_DOMAIN_DIR,
FileUtils.safeGetCanonicalPath(request.domainDir));
props.setProperty(Constants.PROPS_BACKUP_FILE,
FileUtils.safeGetCanonicalPath(request.backupFile));
props.setProperty(Constants.PROPS_DOMAIN_NAME,
request.domainName);
props.setProperty(Constants.PROPS_DESCRIPTION,
request.description);
props.setProperty(Constants.PROPS_TIMESTAMP_HUMAN,
new Date(request.timestamp).toString());
props.setProperty(Constants.PROPS_VERSION,
Version.getFullVersion());
String type = request.configOnly ? Constants.CONFIG_ONLY :
Constants.FULL;
props.setProperty(Constants.PROPS_TYPE, type);
String bc = (request.backupConfig == null) ? Constants.NO_CONFIG : request.backupConfig;
props.setProperty(Constants.BACKUP_CONFIG,bc);
}
代码示例来源:origin: org.glassfish.main.cluster/cluster-cli
private void validateNodeInstallDirLocal(String nodeInstallDir, String installDir) throws CommandValidationException {
String canonicalNodeInstallDir = FileUtils.safeGetCanonicalPath(new File(nodeInstallDir));
String canonicalInstallDir = FileUtils.safeGetCanonicalPath(new File(installDir));
if (canonicalNodeInstallDir == null || canonicalInstallDir == null) {
throw new CommandValidationException(
Strings.get("Instance.installdir.null", node,
canonicalInstallDir, canonicalNodeInstallDir));
}
if ( !canonicalInstallDir.equals(canonicalNodeInstallDir) ) {
throw new CommandValidationException(
Strings.get("Instance.installdir.mismatch", node,
canonicalInstallDir, canonicalNodeInstallDir));
}
}
代码示例来源:origin: eclipse-ee4j/glassfish
public static boolean safeIsRealDirectory(File f) {
if (safeIsDirectory(f) == false)
return false;
// these 2 values while be different for symbolic links
String canonical = safeGetCanonicalPath(f);
String absolute = f.getAbsolutePath();
if (canonical.equals(absolute))
return true;
/* Bug 4715043 -- WHOA -- Bug Obscura!!
* In Windows, if you create the File object with, say, "d:/foo", then the
* absolute path will be "d:\foo" and the canonical path will be "D:\foo"
* and they won't match!!!
**/
if (OS.isWindows() && canonical.equalsIgnoreCase(absolute))
return true;
return false;
}
代码示例来源:origin: org.glassfish.main.common/common-util
public static boolean safeIsRealDirectory(File f) {
if (safeIsDirectory(f) == false)
return false;
// these 2 values while be different for symbolic links
String canonical = safeGetCanonicalPath(f);
String absolute = f.getAbsolutePath();
if (canonical.equals(absolute))
return true;
/* Bug 4715043 -- WHOA -- Bug Obscura!!
* In Windows, if you create the File object with, say, "d:/foo", then the
* absolute path will be "d:\foo" and the canonical path will be "D:\foo"
* and they won't match!!!
**/
if (OS.isWindows() && canonical.equalsIgnoreCase(absolute))
return true;
return false;
}
代码示例来源:origin: org.glassfish.common/common-util
public static boolean safeIsRealDirectory(File f) {
if (safeIsDirectory(f) == false)
return false;
// these 2 values while be different for symbolic links
String canonical = safeGetCanonicalPath(f);
String absolute = f.getAbsolutePath();
if (canonical.equals(absolute))
return true;
/* Bug 4715043 -- WHOA -- Bug Obscura!!
* In Windows, if you create the File object with, say, "d:/foo", then the
* absolute path will be "d:\foo" and the canonical path will be "D:\foo"
* and they won't match!!!
**/
if (OS.isWindows() && canonical.equalsIgnoreCase(absolute))
return true;
return false;
}
代码示例来源:origin: org.glassfish.cluster/cluster-admin
private void validatePath(String propname, String value, String configValue)
throws CommandValidationException {
if (!StringUtils.ok(value) || !StringUtils.ok(configValue)) {
// If no value was passed via the CLI then we don't check it since
// the caller doesn't want it validated.
// If no value exists in the config, then we don't check it since
// we will update it.
return;
}
String canonicalValueFile = FileUtils.safeGetCanonicalPath(new File(value));
String canonicalConfigValueFile = FileUtils.safeGetCanonicalPath(new File(configValue));
if (canonicalConfigValueFile == null || canonicalValueFile== null) {
throw new CommandValidationException(
Strings.get("attribute.null", name,
propname, canonicalValueFile, canonicalConfigValueFile));
}
if ( !canonicalValueFile.equals(canonicalConfigValueFile) ) {
throw new CommandValidationException(
Strings.get("attribute.mismatch", name,
propname, canonicalValueFile, canonicalConfigValueFile));
}
// Don't update an attribute that is considered a match
excludeFromUpdate.add(propname);
}
代码示例来源:origin: org.glassfish.main.cluster/cluster-admin
private void validatePath(String propname, String value, String configValue)
throws CommandValidationException {
if (!StringUtils.ok(value) || !StringUtils.ok(configValue)) {
// If no value was passed via the CLI then we don't check it since
// the caller doesn't want it validated.
// If no value exists in the config, then we don't check it since
// we will update it.
return;
}
String canonicalValueFile = FileUtils.safeGetCanonicalPath(new File(value));
String canonicalConfigValueFile = FileUtils.safeGetCanonicalPath(new File(configValue));
if (canonicalConfigValueFile == null || canonicalValueFile== null) {
throw new CommandValidationException(
Strings.get("attribute.null", name,
propname, canonicalValueFile, canonicalConfigValueFile));
}
if ( !canonicalValueFile.equals(canonicalConfigValueFile) ) {
throw new CommandValidationException(
Strings.get("attribute.mismatch", name,
propname, canonicalValueFile, canonicalConfigValueFile));
}
// Don't update an attribute that is considered a match
excludeFromUpdate.add(propname);
}
代码示例来源:origin: org.glassfish.main.cluster/cluster-cli
filesToZip = resultFiles.toArray(filesToZip);
ZipWriter writer = new ZipWriter(FileUtils.safeGetCanonicalPath(glassFishZipFile), installRoot.toString(), filesToZip);
writer.safeWrite();
logger.info("Created installation zip " + FileUtils.safeGetCanonicalPath(glassFishZipFile));
代码示例来源:origin: org.glassfish.main.admin/backup
String zipName = FileUtils.safeGetCanonicalPath(request.backupFile);
String domainDirName = FileUtils.safeGetCanonicalPath(backupFileDir);
内容来源于网络,如有侵权,请联系作者删除!