/** * Equivalent to {@link #rm_r(File) rm_r(this)}. * * @return {@code this} * @throws IOException if any I/O error occurs. * @see <a href="#bulkIOMethods">Bulk I/O Methods</a> * @see <a href="#traversal">Traversing Directory Trees</a> */ public TFile rm_r() throws IOException { TBIO.rm_r(this, detector); return this; }
/** * Recursively deletes the given file or directory tree. * <p> * If {@code node} is an instance of this * class, its {@link #getArchiveDetector() archive detector} * is used to detect prospective archive files in the directory tree. * Otherwise, * {@link TArchiveDetector#NULL} * is used to detect prospective archive files in the directory tree. * <p> * This file system operation is <em>not</em> atomic. * * @param node the file or directory tree. * 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> * @see <a href="#traversal">Traversing Directory Trees</a> */ public static void rm_r(File node) throws IOException { TBIO.rm_r(node, node instanceof TFile ? ((TFile) node).detector : TArchiveDetector.NULL); }
/** * Recursively deletes the given file or directory tree. * * @param node the file or directory tree to delete recursively. * @throws IOException if an elementary operation fails for any reason. */ static void rm_r(final File node, final TArchiveDetector detector) throws IOException { if (node.isDirectory()) { final String[] members = node.list(); if (null == members) throw new IOException(node + " (cannot list directory)"); for (final String member : members) rm_r(new TFile(node, member, detector), detector); } TFile.rm(node); }