| 1 4 package com.memoire.vainstall; 5 6 import java.io.File ; 7 import java.io.IOException ; 8 import java.net.URI ; 9 10 19 20 public class VAFile extends File { 21 22 public VAFile(File parent, String child) { 23 super(parent, child); 24 } 25 26 public VAFile(String pathname) { 27 super(pathname); 28 } 29 30 public VAFile(String parent, String child) { 31 super(parent, child); 32 } 33 34 public VAFile(URI uri) { 35 super(uri); 36 } 37 38 public VAFile(File file) { 39 super(file.getAbsolutePath()); 40 } 41 42 public boolean canWrite() { 43 boolean answer = super.canWrite(); 44 if (! answer && Setup.IS_WIN && isDirectory()) { 45 answer = canWriteDirectory(); 46 } 47 return answer; 48 } 49 50 public File getParentFile() { 51 return new VAFile(super.getParentFile()); 52 } 53 54 private boolean canWriteDirectory() { 55 boolean answer = false; 56 File f=null; 57 try { 58 f=createTempFile("idw", "tmp", this); 59 answer = true; 60 } catch (IOException ioe) { } finally{ 62 if(f!=null)f.delete(); 63 } 64 return answer; 65 } 66 } 67 | Popular Tags |