/** * Convenience method for {@link #delete(TachyonFile, DeleteOptions)} with default options. */ public void delete(TachyonFile file) throws IOException, TachyonException, FileDoesNotExistException { delete(file, DeleteOptions.defaults()); }
/** * Removes the file specified by argv. * * @param path The TachyonURI path as the input of the command * @return 0 if command is successful, -1 if an error occurred * @throws IOException */ public int rm(TachyonURI path) throws IOException { TachyonFile fd; FileInfo fInfo; try { fd = mTfs.open(path); fInfo = mTfs.getInfo(fd); } catch (TachyonException e) { throw new IOException(e.getMessage()); } if (fInfo.isFolder) { System.out.println("rm: cannot remove a directory, please try rmr <path>"); return -1; } try { mTfs.delete(fd); System.out.println(path + " has been removed"); return 0; } catch (IOException ioe) { return -1; } catch (TachyonException e) { throw new IOException(e.getMessage()); } }
/** * Removes the file or directory specified by argv. Will remove all files and directories in the * directory if a directory is specified. * * @param path The TachyonURI path as the input of the command * @return 0 if command is successful, -1 if an error occurred */ public int rmr(TachyonURI path) { try { DeleteOptions options = new DeleteOptions.Builder(mTachyonConf).setRecursive(true).build(); TachyonFile fd = mTfs.open(path); mTfs.delete(fd, options); System.out.println(path + " has been removed"); return 0; } catch (IOException e) { return -1; } catch (TachyonException e) { return -1; } }
private FileOutStream getOrCreate(TachyonFileSystem tachyonFileSystem, TachyonURI filePath, boolean deleteIfExists, OutStreamOptions clientOptions) throws IOException, TachyonException { TachyonFile file; try { file = tachyonFileSystem.open(filePath); } catch (Exception e) { file = null; } if (file == null) { // file doesn't exist yet, so create it return tachyonFileSystem.getOutStream(filePath, clientOptions); } else if (deleteIfExists) { // file exists, so delete it and recreate tachyonFileSystem.delete(file); return tachyonFileSystem.getOutStream(filePath, clientOptions); } // file exists and deleteIfExists is false throw new FileAlreadyExistsException(" file exists but deleteIfExists is false"); }
sOldTfs = TachyonFS.get(ClientContext.getConf()); try { sTfs.delete(sTfs.open(new TachyonURI(sTestDir))); } catch (Exception ioe) {
throw e; sTfs.delete(sTfs.open(testURI)); } else if (ClientOpType.CREATE_RENAME_FILE == mOpType) { try {