提交 b99aea62 authored 作者: Thomas Mueller's avatar Thomas Mueller

Slightly simplified code, link to root cause

上级 46538a69
......@@ -270,30 +270,28 @@ public class FileSystemDisk extends FileSystem {
fileName = translateFileName(fileName);
return canWriteInternal(new File(fileName));
}
private boolean canWriteInternal(File file) {
if (file.canWrite()) {
// Does not respect windows user permissions,
// so we must try to open it mode "rw".
// See also http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4420020
RandomAccessFile randomAccessFile = null;
try {
randomAccessFile = new RandomAccessFile(file, "rw");
} catch (FileNotFoundException e) {
return false;
} finally {
if (randomAccessFile != null) {
try {
randomAccessFile.close();
} catch (Exception e) {
// ignore
}
}
}
private boolean canWriteInternal(File file) {
if (!file.canWrite()) {
return false;
}
// File.canWrite() does not respect windows user permissions,
// so we must try to open it using the mode "rw".
// See also http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4420020
RandomAccessFile r = null;
try {
r = new RandomAccessFile(file, "rw");
return true;
} else {
} catch (FileNotFoundException e) {
return false;
} finally {
if (r != null) {
try {
r.close();
} catch (IOException e) {
// ignore
}
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论