mirror of
https://github.com/corda/corda.git
synced 2025-06-15 05:38:14 +00:00
ignore leading / for files on Windows (fixes #452)
This commit is contained in:
@ -14,6 +14,9 @@ public class File implements Serializable {
|
||||
private static final String FileSeparator
|
||||
= System.getProperty("file.separator");
|
||||
|
||||
private static final boolean IsWindows
|
||||
= System.getProperty("os.name").equals("Windows");
|
||||
|
||||
public static final String separator = FileSeparator;
|
||||
|
||||
public static final char separatorChar = FileSeparator.charAt(0);
|
||||
@ -89,6 +92,14 @@ public class File implements Serializable {
|
||||
}
|
||||
|
||||
private static String normalize(String path) {
|
||||
if(IsWindows
|
||||
&& path.length() > 2
|
||||
&& path.charAt(0) == '/'
|
||||
&& path.charAt(2) == ':')
|
||||
{
|
||||
// remove a leading slash on Windows
|
||||
path = path.substring(1);
|
||||
}
|
||||
return stripSeparators
|
||||
("\\".equals(FileSeparator) ? path.replace('/', '\\') : path);
|
||||
}
|
||||
|
Reference in New Issue
Block a user