/** * Renames this file. * * @param path the new name * @return true if succeed, false otherwise * @throws IOException if an event that prevent the operation from completing is encountered */ public boolean rename(TachyonURI path) throws IOException { return mTachyonFS.rename(mFileId, path); }
@Override public boolean rename(Path src, Path dst) throws IOException { LOG.info("rename(" + src + ", " + dst + ")"); if (mStatistics != null) { mStatistics.incrementWriteOps(1); } TachyonURI srcPath = new TachyonURI(Utils.getPathWithoutScheme(src)); TachyonURI dstPath = new TachyonURI(Utils.getPathWithoutScheme(dst)); FileInfo info; try { info = mTFS.getFileStatus(-1, dstPath); } catch (IOException ioe) { info = null; } // If the destination is an existing folder, try to move the src into the folder if (info != null && info.isFolder) { dstPath = dstPath.join(srcPath.getName()); } try { return mTFS.rename(srcPath, dstPath); } catch (IOException ioe) { LOG.error("Failed to rename {} to {}", src, dst, ioe); return false; } }