/** * Looking for an existing file, in cache or no * @param fileLocation the original name * @return existing file if you can find it */ public File getExistingFileOrCache(String fileLocation) { File f = new File(fileLocation); if (f.exists()) return f; File fc = new File(makeCachePath(fileLocation)); if (fc.exists()) return fc; return null; }
/** * Looking for an existing file, in cache or no * @param fileLocation the original name * @return existing file if you can find it */ public File getExistingFileOrCache(String fileLocation) { File f = new File(fileLocation); if (f.exists()) return f; if (neverUseCache) return null; File fc = new File(makeCachePath(fileLocation)); if (fc.exists()) return fc; return null; }
/** * Get a File in the cache, corresponding to the fileLocation. * File may or may not exist. * If fileLocation has "/" in it, and cachePathPolicy == NestedDirectory, the * nested directories will be created. * * @param fileLocation logical file location * @return physical File in the cache. */ public File getCacheFile(String fileLocation) { if (!alwaysUseCache) { File f = new File(fileLocation); if (canWrite(f)) return f; } File f = new File(makeCachePath(fileLocation)); //if (f.exists()) // f.setLastModified( System.currentTimeMillis()); if (cachePathPolicy == CachePathPolicy.NestedDirectory) { File dir = f.getParentFile(); dir.mkdirs(); } return f; }
/** * Get a File in the cache, corresponding to the fileLocation. * File may or may not exist. * If fileLocation has "/" in it, and cachePathPolicy == NestedDirectory, the * nested directories will be created. * * @param fileLocation logical file location * @return physical File in the cache. */ public File getCacheFile(String fileLocation) { if (neverUseCache) return null; if (!alwaysUseCache) { File f = new File(fileLocation); if (canWrite(f)) return f; } File f = new File(makeCachePath(fileLocation)); //if (f.exists()) // f.setLastModified( System.currentTimeMillis()); if (cachePathPolicy == CachePathPolicy.NestedDirectory) { File dir = f.getParentFile(); boolean ret = dir.mkdirs(); if (!ret) cacheLog.warn("Error creating dir: " + dir); } return f; }
/** * Get a File in the cache, corresponding to the fileLocation. * File may or may not exist. * If fileLocation has "/" in it, and cachePathPolicy == NestedDirectory, the * nested directories will be created. * * @param fileLocation logical file location * @return physical File in the cache. */ public File getCacheFile(String fileLocation) { if (neverUseCache) return null; if (!alwaysUseCache) { File f = new File(fileLocation); if (canWrite(f)) return f; } File f = new File(makeCachePath(fileLocation)); //if (f.exists()) // f.setLastModified( System.currentTimeMillis()); if (cachePathPolicy == CachePathPolicy.NestedDirectory) { File dir = f.getParentFile(); if (!dir.exists()) { boolean ret = dir.mkdirs(); if (!ret) cacheLog.warn("Error creating dir: " + dir); } } return f; }
/** * Get the named File. * If exists or isWritable, return it. * Otherwise get corresponding file in the cache directory. * * If fileLocation has "/" in it, and cachePathPolicy == NestedDirectory, the * nested directories will be created. * * @param fileLocation logical file location * @return physical File as named, or in the cache. */ public File getFile(String fileLocation) { if (!alwaysUseCache) { File f = new File(fileLocation); if (f.exists()) return f; if (canWrite(f)) return f; } if (neverUseCache) { throw new IllegalStateException("neverUseCache=true, but directory is not writeable ="+fileLocation); } File f = new File(makeCachePath(fileLocation)); if (cachePathPolicy == CachePathPolicy.NestedDirectory) { File dir = f.getParentFile(); if (!dir.exists() && !dir.mkdirs()) cacheLog.warn("Cant create directories for file "+dir.getPath()); } return f; }
/** * Get the named File. * If exists or isWritable, return it. * Otherwise get corresponding file in the cache directory. * * If fileLocation has "/" in it, and cachePathPolicy == NestedDirectory, the * nested directories will be created. * * @param fileLocation logical file location * @return physical File as named, or in the cache. */ public File getFile(String fileLocation) { if (!alwaysUseCache) { File f = new File(fileLocation); if (f.exists()) return f; if (canWrite(f)) return f; } if (neverUseCache) { throw new IllegalStateException("neverUseCache=true, but file does not exist and directory is not writeable ="+fileLocation); } File f = new File(makeCachePath(fileLocation)); if (cachePathPolicy == CachePathPolicy.NestedDirectory) { File dir = f.getParentFile(); if (!dir.exists() && !dir.mkdirs()) cacheLog.warn("Cant create directories for file "+dir.getPath()); } return f; }
/** * Get the named File. * If exists or isWritable, return it. * Otherwise get corresponding file in the cache directory. * * If fileLocation has "/" in it, and cachePathPolicy == NestedDirectory, the * nested directories will be created. * * @param fileLocation logical file location * @return physical File as named, or in the cache. */ public File getFile(String fileLocation) { if (!alwaysUseCache) { File f = new File(fileLocation); if (f.exists()) return f; if (canWrite(f)) return f; } if (neverUseCache) { throw new IllegalStateException("neverUseCache=true, but file does not exist and directory is not writeable ="+fileLocation); } File f = new File(makeCachePath(fileLocation)); if (cachePathPolicy == CachePathPolicy.NestedDirectory) { File dir = f.getParentFile(); if (!dir.exists() && !dir.mkdirs()) cacheLog.warn("Cant create directories for file "+dir.getPath()); } return f; }