private StaleFileManager staleFileManager() { ReadableArchive parent = getParentArchive(); if (parent == null) { return staleFileManager; } if (parent instanceof FileArchive) { return ((FileArchive) parent).staleFileManager(); } else { return null; } }
private boolean isEntryValid(final File entry, final boolean isLogging, final Logger logger) { return staleFileManager().isEntryValid(entry, isLogging, logger); }
/** * @returns an @see java.io.OutputStream for a new entry in this * current abstract archive. * @param name the entry name */ @Override public OutputStream putNextEntry(String name) throws java.io.IOException { name = name.replace('/', File.separatorChar); File newFile = new File(archive, name); if (newFile.exists()) { if (!deleteEntry(name, false /* isLogging */)) { logger.log(Level.FINE, "Could not delete file {0} in FileArchive {1} during putNextEntry; continuing", new Object[]{name, uri.toASCIIString()}); } } // if the entry name contains directory structure, we need // to create those directories first. if (name.lastIndexOf(File.separatorChar)!=-1) { String dirs = name.substring(0, name.lastIndexOf(File.separatorChar)); (new File(archive, dirs)).mkdirs(); } staleFileManager().recordValidEntry(newFile); os = new BufferedOutputStream(new FileOutputStream(newFile)); return os; }
/** * create or obtain an embedded archive within this abstraction. * * @param name name of the embedded archive. */ @Override public WritableArchive createSubArchive(String name) throws IOException { String subEntryName = getFileSubArchivePath(name); File subEntry = new File(subEntryName); if (!subEntry.exists()) { // time to create a new sub directory subEntry.mkdirs(); logger.log(DEBUG_LEVEL, "FileArchive.createSubArchive created dirs for {0}", subEntry.getAbsolutePath()); } else { logger.log(DEBUG_LEVEL, "FileArchive.createSubArchive found existing dir for {0}", subEntry.getAbsolutePath()); /* * This subdirectory already exists, so it might be marked as * stale. Because this invocation is creating the subarchive in * the current archive, the subdirectory is no longer stale. */ staleFileManager().recordValidEntry(subEntry); } final WritableArchive result = archiveFactory.createArchive(subEntry); if (result instanceof AbstractReadableArchive) { ((AbstractReadableArchive) result).setParentArchive(this); } return result; }