/** * Equivalent to {@link #mv(File, File, TArchiveDetector) mv(this, dst, getArchiveDetector())}. * * @param dst the destination 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. * @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 mv(File dst) throws IOException { mv(this, dst, detector); return this; }
/** * {@inheritDoc} * * @param dst the destination 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. * @return {@code true} on success or {@code false} otherwise. * @deprecated This method just returns a boolean value to indicate failure, * which is hard to analyze. * @see #mv(File) */ @Deprecated @Override public boolean renameTo(final File dst) { try { mv(this, dst, detector); return true; } catch (IOException ex) { return false; } }
public void moveFile( TFile source, TFile dest ) throws IOException { TFile file = new TFile( source ); TFile tofile = new TFile( dest ); file.mv( tofile ); }
/** * Moves {@code oldNode} to {@code node} * and updates the tree accordingly. * Note that the current selection may get lost. * * @throws IOException On any I/O failure. */ public void mv(TFile oldNode, TFile node) throws IOException { oldNode.mv(node); nodeRemoved(oldNode); nodeInserted(node); }
if (tmp.isFile()) tmp.rm(); src.mv(tmp); } catch (IOException ex) { throw new IOException(src + ": " + resources.getString("cpOrMv.cmt") + ": " + tmp, ex);
private void assertRenameTo(TPath src, TPath dst) throws IOException { assertTrue(exists(src)); assertFalse(exists(dst)); assertFalse(exists(dst.toNonArchivePath())); assert TConfig.get().isLenient(); src.toFile().mv(dst.toFile()); assertFalse(exists(src)); assertFalse(exists(src.toNonArchivePath())); assertTrue(exists(dst)); }
private void roundTrip(final TFile outer) throws IOException { final TFile inner = new TFile(outer.getParentFile(), "inner" + getSuffix() + "/" + outer.getName()); // This particular sequence has been selected because of its increased // likeliness to fail in case the cache sync logic is not correct. create(inner); check(inner); inner.mv(outer); check(outer); outer.mv(inner); check(inner); inner.rm(); }
private void assertRenameArchiveToTemp(final TPath archive) throws IOException { assert archive.isArchive(); // regular archive or false positive assert !archive.isEntry(); // not contained in another archive file // Create a temporary file. TPath tmp = new TPath(Files.createTempFile(TEMP_FILE_PREFIX, null)); delete(tmp); assertFalse(exists(tmp)); assertFalse(exists(tmp.toNonArchivePath())); // Now rename the archive to the temporary path. // Depending on the true state of the object "archive", this will // either create a directory (iff archive is a regular archive) or a // plain file (iff archive is a false positive). archive.toFile().mv(tmp.toFile()); assertFalse(exists(archive)); assertFalse(exists(archive.toNonArchivePath())); // Now delete resulting temporary file or directory. tmp.toFile().rm_r(); assertFalse(exists(tmp)); assertFalse(exists(tmp.toNonArchivePath())); }
private void assertRenameTo(TFile src, TFile dst) throws IOException { assertTrue(src.exists()); assertFalse(dst.exists()); assertFalse(dst.toNonArchiveFile().exists()); assert TConfig.get().isLenient(); src.mv(dst); assertFalse(src.exists()); assertFalse(src.toNonArchiveFile().exists()); assertTrue(dst.exists()); }
private void assertRenameArchiveToTemp(final TFile archive) throws IOException { assert archive.isArchive(); // regular archive or false positive assert !archive.isEntry(); // not contained in another archive file // Create a temporary file. TFile tmp = new TFile(TFile.createTempFile(TEMP_FILE_PREFIX, null)); tmp.rm(); assertFalse(tmp.exists()); assertFalse(tmp.toNonArchiveFile().exists()); // Now rename the archive to the temporary path. // Depending on the true state of the object "archive", this will // either create a directory (iff archive is a regular archive) or a // plain file (iff archive is a false positive). archive.mv(tmp); assertFalse(archive.exists()); assertFalse(archive.toNonArchiveFile().exists()); // Now delete resulting temporary file or directory. tmp.rm_r(); assertFalse(tmp.exists()); assertFalse(tmp.toNonArchiveFile().exists()); }