public ArchiveEntry createEntry(String name) throws IOException { String path = ArchiveUtil.generateFullPath(folderName, name); File fd = new File(path); ArchiveUtil.createParentFolder(fd); FolderArchiveEntry out = new FolderArchiveEntry(path, fd, inputStreams, outputStreams); return out; }
public ArchiveEntry openEntry(String name) throws IOException { String fullPath = ArchiveUtil.generateFullPath(folderName, name); File fd = new File(fullPath); if (fd.exists()) { return new FolderArchiveEntry(fullPath, fd, inputStreams, outputStreams); } throw new FileNotFoundException(fullPath); }
public boolean removeEntry(String name) throws IOException { String path = ArchiveUtil.generateFullPath(folderName, name); try { File fd = new File(path); return ArchiveUtil.removeFileAndFolder(fd); } finally { synchronized (outputStreams) { ArrayList<RAFolderOutputStream> outputs = new ArrayList<RAFolderOutputStream>(outputStreams); for (RAFolderOutputStream output : outputs) { try { if (path.equals(output.getName())) { output.close(); } } catch (IOException ex) { logger.log(Level.SEVERE, ex.getMessage(), ex); throw ex; } } } } }
public List<String> listEntries(String namePattern) { ArrayList<String> streamList = new ArrayList<String>(); String storagePath = ArchiveUtil.generateFullPath(folderName, namePattern); File dir = new File(storagePath); if (dir.exists() && dir.isDirectory()) { File[] files = dir.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isFile()) { String relativePath = ArchiveUtil.generateRelativePath(folderName, file.getPath()); if (!ArchiveUtil.needSkip(relativePath)) { streamList.add(relativePath); } } } } } return streamList; }
public Object lockEntry(String entry) throws IOException { String path = ArchiveUtil.generateFullPath(folderName, entry + ".lck"); IArchiveLockManager lockManager = ArchiveLockManager.getInstance(); return lockManager.lock(path); }
public boolean exists(String name) { String path = ArchiveUtil.generateFullPath(folderName, name); File fd = new File(path); return fd.exists(); }