/** * Open an abstract archive * @param uri path to the archive */ @Override public void open(URI uri) throws IOException { if (!uri.getScheme().equals("file")) { throw new IOException("Wrong scheme for FileArchive : " + uri.getScheme()); } this.uri = uri; archive = new File(uri); if (!archive.exists()) { throw new FileNotFoundException(uri.getSchemeSpecificPart()); } staleFileManager = StaleFileManager.Util.getInstance(archive); }
/** * Creates a marker file in the archive directory - if it still * exists and contains any stale files. * @param archive the File for the archive to mark */ public static void markDeletedArchive(final File archiveFile) { if ( ! archiveFile.exists()) { return; } final Iterator<File>staleFileIt = findFiles(archiveFile); if ( ! staleFileIt.hasNext()) { return; } final URI archiveURI = archiveFile.toURI(); PrintStream ps = null; try { ps = new PrintStream(markerFile(archiveFile)); } catch (FileNotFoundException ex) { throw new RuntimeException(ex); } for ( ; staleFileIt.hasNext(); ) { final URI relativeURI = archiveURI.relativize(staleFileIt.next().toURI()); ps.println(relativeURI); logger.log(DEBUG_LEVEL, "FileArchive.StaleFileManager recording left-over file {0}", relativeURI); } ps.close(); }
/** * delete the archive */ @Override public boolean delete() { // delete the directory structure... try { final boolean result = deleteDir(archive); /* * Create the stale file marker file, if needed. */ StaleFileManager.Util.markDeletedArchive(this); return result; } catch (IOException e) { return false; } }
/** * creates a new abstract archive with the given path * @param uri path to create the archive */ @Override public void create(URI uri) throws IOException { this.uri = uri; archive = new File(uri); /* * Get the stale file manager before creating the directories; it's * slightly faster that way. */ staleFileManager = StaleFileManager.Util.getInstance(archive); archive.mkdirs(); }
ArchiveIntrospectionFilter(String root) { try { sfm = FileArchive.StaleFileManager.Util.getInstance( new File(root)); } catch (IOException ex) { throw new RuntimeException(ex); } libDir = root + File.separator + "lib" + File.separator; }
ArchiveIntrospectionFilter(String root) { try { sfm = FileArchive.StaleFileManager.Util.getInstance( new File(root)); } catch (IOException ex) { throw new RuntimeException(ex); } libDir = root + File.separator + "lib" + File.separator; }
/** * Creates a marker file in the archive directory - if it still * exists and contains any stale files. * @param archive the File for the archive to mark */ public static void markDeletedArchive(final Archive archive) { if ( ! (archive instanceof FileArchive)) { return; } final File archiveFile = new File(archive.getURI()); markDeletedArchive(archiveFile); }