Updated refactored Normalize for strings (not to be confused with
NormalizeRaw)
This commit is contained in:
parent
a7548cad84
commit
6589d6f95b
|
@ -212,8 +212,8 @@ class FileUtil {
|
|||
}
|
||||
|
||||
|
||||
String normalizedIn = normalize(in.getAbsolutePath());
|
||||
String normalizedout = normalize(out.getAbsolutePath());
|
||||
String normalizedIn = normalize(in).getAbsolutePath();
|
||||
String normalizedout = normalize(out).getAbsolutePath();
|
||||
|
||||
if (normalizedIn.equalsIgnoreCase(normalizedout)) {
|
||||
logger.warn("Source equals destination! " + normalizedIn);
|
||||
|
@ -277,8 +277,8 @@ class FileUtil {
|
|||
throw new IllegalArgumentException("two cannot be null.");
|
||||
}
|
||||
|
||||
String normalizedOne = normalize(one.getAbsolutePath());
|
||||
String normalizedTwo = normalize(two.getAbsolutePath());
|
||||
String normalizedOne = normalize(one).getAbsolutePath();
|
||||
String normalizedTwo = normalize(two).getAbsolutePath();
|
||||
|
||||
Logger logger2 = logger;
|
||||
if (logger2.isTraceEnabled()) {
|
||||
|
@ -511,7 +511,7 @@ class FileUtil {
|
|||
boolean delete = true;
|
||||
final File file2 = files[i];
|
||||
String name2 = file2.getName();
|
||||
String name2Full = normalize(file2.getAbsolutePath());
|
||||
String name2Full = normalize(file2).getAbsolutePath();
|
||||
|
||||
if (file2.isDirectory()) {
|
||||
for (String name : namesToIgnore) {
|
||||
|
@ -1175,6 +1175,7 @@ class FileUtil {
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* FilenameUtils.java (normalize + dependencies) - Apache 2.0 License
|
||||
* http://commons.apache.org/proper/commons-io/
|
||||
|
@ -1187,6 +1188,8 @@ class FileUtil {
|
|||
/**
|
||||
* Normalizes a path, removing double and single dot path steps.
|
||||
* <p/>
|
||||
* THIS IS DIFFERENT in that it might not be a path that resolves to anything
|
||||
* <p/>
|
||||
* This method normalizes a path to a standard format.
|
||||
* The input may contain separators in either Unix or Windows format.
|
||||
* The output will contain separators in the format of the system.
|
||||
|
@ -1222,10 +1225,11 @@ class FileUtil {
|
|||
* (Note the file separator returned will be correct for Windows/Unix)
|
||||
*
|
||||
* @param filename the filename to normalize, null returns null
|
||||
*
|
||||
* @return the normalized filename, or null if invalid
|
||||
*/
|
||||
public static
|
||||
String normalize(String filename) {
|
||||
String normalizeRaw(String filename) {
|
||||
return doNormalize(filename, SYSTEM_SEPARATOR, true);
|
||||
}
|
||||
|
||||
|
@ -1275,12 +1279,21 @@ class FileUtil {
|
|||
* </pre>
|
||||
* (Note the file separator returned will be correct for Windows/Unix)
|
||||
*
|
||||
* @param filename the filename to normalize, null returns null
|
||||
* @return the normalized filename, or null if invalid
|
||||
* @param file the file to normalize, null returns null
|
||||
* @return the normalized file, or null if invalid
|
||||
*/
|
||||
public static
|
||||
String normalizeAsFile(String filename) {
|
||||
return doNormalize(new File(filename).getAbsolutePath(), SYSTEM_SEPARATOR, true);
|
||||
File normalize(String filename) {
|
||||
if (filename == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String asString = doNormalize(new File(filename).getAbsolutePath(), SYSTEM_SEPARATOR, true);
|
||||
if (asString == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new File(asString);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -15,15 +15,15 @@
|
|||
*/
|
||||
package dorkbox.util.process;
|
||||
|
||||
import dorkbox.util.FileUtil;
|
||||
import dorkbox.util.OS;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dorkbox.util.FileUtil;
|
||||
import dorkbox.util.OS;
|
||||
|
||||
/**
|
||||
* This will FORK the java process initially used to start the currently running JVM. Changing the java executable will change this behaviors
|
||||
*/
|
||||
|
@ -61,8 +61,8 @@ class JavaProcessBuilder extends ShellProcessBuilder {
|
|||
// even though the former is a symlink to the latter! To work around this, see if the
|
||||
// desired jvm is in fact pointed to by /usr/bin/java and, if so, use that instead.
|
||||
if (OS.isMacOsX()) {
|
||||
String localVM = FileUtil.normalize(new File("/usr/bin/java").getAbsolutePath());
|
||||
String vmCheck = FileUtil.normalize(new File(vmpath).getAbsolutePath());
|
||||
String localVM = FileUtil.normalize("/usr/bin/java").getAbsolutePath();
|
||||
String vmCheck = FileUtil.normalize(vmpath).getAbsolutePath();
|
||||
if (localVM.equals(vmCheck)) {
|
||||
vmpath = "/usr/bin/java";
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ class JavaProcessBuilder extends ShellProcessBuilder {
|
|||
for (String classpathEntry : this.classpathEntries) {
|
||||
try {
|
||||
// make sure the classpath is ABSOLUTE pathname
|
||||
classpathEntry = FileUtil.normalize(new File(classpathEntry).getAbsolutePath());
|
||||
classpathEntry = FileUtil.normalize(classpathEntry).getAbsolutePath();
|
||||
|
||||
// fix a nasty problem when spaces aren't properly escaped!
|
||||
classpathEntry = classpathEntry.replaceAll(" ", "\\ ");
|
||||
|
|
Loading…
Reference in New Issue
Block a user