File.setWritable should be the first, and if possible only, thing we try for makeWritable.

This commit is contained in:
Jesse Glick committed 2013-03-19 10:13:19 -04:00
1 parent 4d8843c991
commit 606a9e1de9
1 file changed
+9 -7
+9 -7
View File
@@ -252,6 +252,15 @@ public class Util {
*/
@IgnoreJRERequirement
private static void makeWritable(File f) {
// try JDK6-way of doing it.
try {
if (f.setWritable(true)) {
return;
}
} catch (NoSuchMethodError e) {
// not JDK6
}
// try chmod. this becomes no-op if this is not Unix.
try {
Chmod chmod = new Chmod();
@@ -263,13 +272,6 @@ public class Util {
LOGGER.log(Level.INFO,"Failed to chmod "+f,e);
}
// also try JDK6-way of doing it.
try {
f.setWritable(true);
} catch (NoSuchMethodError e) {
// not JDK6
}
try {// try libc chmod
POSIX posix = PosixAPI.get();
String path = f.getAbsolutePath();