提交 6d129986 authored 作者: Thomas Mueller's avatar Thomas Mueller

Improved compatibility with the Java 7 FileSystem abstraction.

上级 bbf6e17f
...@@ -42,11 +42,13 @@ public abstract class FilePath { ...@@ -42,11 +42,13 @@ public abstract class FilePath {
/** /**
* Get the file path object for the given path. * Get the file path object for the given path.
* Windows-style '\' is replaced with '/'.
* *
* @param path the path * @param path the path
* @return the file path object * @return the file path object
*/ */
public static FilePath get(String path) { public static FilePath get(String path) {
path = path.replace('\\', '/');
int index = path.indexOf(':'); int index = path.indexOf(':');
if (index < 2) { if (index < 2) {
// use the default provider if no prefix or // use the default provider if no prefix or
......
...@@ -43,19 +43,20 @@ public class FilePathDisk extends FilePath { ...@@ -43,19 +43,20 @@ public class FilePathDisk extends FilePath {
} }
/** /**
* Translate the file name to the native format. * Translate the file name to the native format. This will replace '\' with
* This will expand the home directory (~). * '/' and expand the home directory ('~').
* *
* @param fileName the file name * @param fileName the file name
* @return the native file name * @return the native file name
*/ */
protected static String translateFileName(String fileName) { protected static String translateFileName(String fileName) {
fileName = fileName.replace('\\', '/');
return expandUserHomeDirectory(fileName); return expandUserHomeDirectory(fileName);
} }
/** /**
* Expand '~' to the user home directory. It is only be expanded if the ~ * Expand '~' to the user home directory. It is only be expanded if the '~'
* stands alone, or is followed by / or \. * stands alone, or is followed by '/' or '\'.
* *
* @param fileName the file name * @param fileName the file name
* @return the native file name * @return the native file name
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论