Fix symbolic file(or contains symbolic directory) check condition#519
Conversation
|
Let's replace all the calls, not just that one. However, |
|
I tested on Android 25 API Level. |
|
Frequently compare platform string to "windows" seems slow... How about implementing a one-time check(consider volatile or syncronoized) or enum for platform? |
|
We can use something like BTW, there are other places in the code where |
@saudet How about like this? /** Value created out of "java.vm.name", "os.name", and "os.arch" system properties.
* Returned by {@link #getPlatform()} and initialized with {@link Detector#getPlatform()}. */
private static final String PLATFORM = Detector.getPlatform();
/**
* Returned an enumeration of known operating systems and initialized with {@link Detector#getOperatingSystem()}.
*/
private static final Detector.OperatingSystem OPERATING_SYSTEM = Detector.getOperatingSystem();
public static class Detector {
public enum OperatingSystem {
WINDOWS, LINUX, ANDROID, MACOSX, IOS, OTHER;
/**
* @return Parsed pre-defined operating system enum
*/
static OperatingSystem parse(String string) {
if (string != null){
string = string.toLowerCase();
if (string.startsWith("windows")) {
return OperatingSystem.WINDOWS;
} else if (string.startsWith("linux")) {
return OperatingSystem.LINUX;
} else if (string.startsWith("android")) {
return OperatingSystem.ANDROID;
} else if (string.startsWith("macosx")) {
return OperatingSystem.MACOSX;
} else if (string.startsWith("ios")) {
return OperatingSystem.IOS;
}
}
return OperatingSystem.OTHER;
}
}
public static OperatingSystem getOperatingSystem(){
return OperatingSystem.parse(Detector.getPlatform());
}
...
}I think it's better than making a field just for windows. |
|
No, let's just leave it as a string. That just adds unnecessary complexity. |
file.getCanonicalFile()is not solve symbolic link in Windows environment (See issue)So i change to more precise method
toRealPath().