/** * Returns <code>true</code> if this entry exists within the archive file. * * @return true if this entry exists within the archive file */ @Override public boolean exists() { return entry.exists(); }
/** * @throws IOException if the entry does not exist within the archive */ @Override public void changeDate(long lastModified) throws IOException, UnsupportedFileOperationException { if(!entry.exists()) throw new IOException(); long oldDate = entry.getDate(); entry.setDate(lastModified); boolean success = updateEntryAttributes(); if(!success) { // restore old date if attributes could not be updated entry.setDate(oldDate); throw new IOException(); } }
@Override public void changePermissions(int permissions) throws IOException { if(!entry.exists()) throw new IOException(); FilePermissions oldPermissions = entry.getPermissions(); FilePermissions newPermissions = new SimpleFilePermissions(permissions, oldPermissions.getMask()); entry.setPermissions(newPermissions); boolean success = updateEntryAttributes(); if(!success) // restore old permissions if attributes could not be updated entry.setPermissions(oldPermissions); if(!success) throw new IOException(); } }
/** * Creates this entry as a directory in the associated <code>AbstractArchiveFile</code>. * <p> * Throws a {@link UnsupportedFileOperationException} if if the underlying file does not support the required * read and write {@link FileOperation file operations}. Throws an <code>IOException</code> if this entry * already exists in the archive or if an I/O error occurred. * </p> * * @throws IOException if this entry already exists in the archive or if an I/O error occurred. * @throws UnsupportedFileOperationException if the underlying archive file does not support the required read and * write {@link FileOperation file operations}. */ @Override public void mkdir() throws IOException, UnsupportedFileOperationException { if(entry.exists()) throw new IOException(); AbstractRWArchiveFile rwArchivefile = (AbstractRWArchiveFile)archiveFile; // Update the ArchiveEntry entry.setDirectory(true); entry.setDate(System.currentTimeMillis()); entry.setSize(0); // Add the entry to the archive file rwArchivefile.addEntry(entry); // The entry now exists entry.setExists(true); }
if(entry.exists()) { try { delete();
if(!entry.exists()) throw new IOException();