/** * debug * * @param filename look for this file * @throws java.io.IOException if read error */ static void make(String filename) throws IOException { File want = DiskCache.getCacheFile(filename); System.out.println("make=" + want.getPath() + "; exists = " + want.exists()); if (!want.exists()) want.createNewFile(); System.out.println(" canRead= " + want.canRead() + " canWrite = " + want.canWrite() + " lastMod = " + new Date(want.lastModified())); System.out.println(" original=" + filename); }
/** * debug * * @param filename look for this file * @throws java.io.IOException if read error */ static void make(String filename) throws IOException { File want = DiskCache.getCacheFile(filename); System.out.println("make=" + want.getPath() + "; exists = " + want.exists()); if (!want.exists()) { boolean ret = want.createNewFile(); assert ret; } System.out.println(" canRead= " + want.canRead() + " canWrite = " + want.canWrite() + " lastMod = " + new Date(want.lastModified())); System.out.println(" original=" + filename); }
/** * Get a File if it exists. If not, get a File that can be written to. * If alwaysInCache, look only in the cache, otherwise, look in the "normal" location first, * then in the cache. * <p> * * @param fileLocation normal file location * @param alwaysInCache true if you want to look only in the cache * @return a File that either exists or is writeable. */ static public File getFile(String fileLocation, boolean alwaysInCache) { if (alwaysInCache) { return getCacheFile(fileLocation); } else { File f = new File(fileLocation); if (f.exists()) return f; // now comes the tricky part to make sure we can open and write to it try { if (!simulateUnwritableDir && f.createNewFile()) { boolean ret = f.delete(); assert ret; return f; } } catch (IOException e) { // cant write to it - drop through } return getCacheFile(fileLocation); } }
/** * debug * * @param filename look for this file * @throws java.io.IOException if read error */ static void make(String filename) throws IOException { File want = DiskCache.getCacheFile(filename); System.out.println("make=" + want.getPath() + "; exists = " + want.exists()); if (!want.exists()) { boolean ret = want.createNewFile(); assert ret; } System.out.println(" canRead= " + want.canRead() + " canWrite = " + want.canWrite() + " lastMod = " + new Date(want.lastModified())); System.out.println(" original=" + filename); }
/** * Get a File if it exists. If not, get a File that can be written to. * If alwaysInCache, look only in the cache, otherwise, look in the "normal" location first, * then in the cache. * <p/> * * @param fileLocation normal file location * @param alwaysInCache true if you want to look only in the cache * @return a File that either exists or is writeable. */ static public File getFile(String fileLocation, boolean alwaysInCache) { if (alwaysInCache) { return getCacheFile(fileLocation); } else { File f = new File(fileLocation); if (f.exists()) return f; // now comes the tricky part to make sure we can open and write to it try { if ( ! simulateUnwritableDir && f.createNewFile()) { f.delete(); return f; } } catch (IOException e) { // cant write to it - drop through } return getCacheFile(fileLocation); } }
/** * Get a File if it exists. If not, get a File that can be written to. * If alwaysInCache, look only in the cache, otherwise, look in the "normal" location first, * then in the cache. * <p/> * * @param fileLocation normal file location * @param alwaysInCache true if you want to look only in the cache * @return a File that either exists or is writeable. */ static public File getFile(String fileLocation, boolean alwaysInCache) { if (alwaysInCache) { return getCacheFile(fileLocation); } else { File f = new File(fileLocation); if (f.exists()) return f; // now comes the tricky part to make sure we can open and write to it try { if ( ! simulateUnwritableDir && f.createNewFile()) { boolean ret = f.delete(); assert ret; return f; } } catch (IOException e) { // cant write to it - drop through } return getCacheFile(fileLocation); } }