void delete(TPath path) throws IOException { getController().unlink(path.getEntryName(), path.getOutputPreferences()); }
/** * Deletes the given file or directory. * If the file is a directory, it must be empty. * * @param node the file or directory. * Note that although this just needs to be a plain {@code File}, * archive files and entries are only supported for instances of * this class. * @throws IOException if any I/O error occurs. * @see <a href="#bulkIOMethods">Bulk I/O Methods</a> */ public static void rm(File node) throws IOException { if (node instanceof TFile) { TFile file = (TFile) node; if (null != file.innerArchive) { file.innerArchive.getController().unlink( file.getInnerFsEntryName(), TConfig.get().getOutputPreferences()); return; } node = file.file; } if (!node.delete()) throw new IOException(node + " (cannot delete)"); }
@Override public void unlink(final FsEntryName name, BitField<FsOutputOption> options) throws IOException { try { delegate.unlink(name, options); } catch (final ControlFlowException ex) { // If the exception is caused by a key exception, then throw this // cause instead in order to avoid treating the target archive file // like a false positive and routing this operation to the parent // file system. // This prevents the application from inadvertently deleting an // encrypted ZIP file just because the user cancelled key prompting. final IOException keyEx = findKeyException(ex); if (null != keyEx) throw keyEx; throw ex; } if (name.isRoot()) getKeyManager().removeKeyProvider( driver.resourceUri(getModel(), name.toString())); }