private Path makeTrashRelativePath(Path basePath, Path rmFilePath) { return Path.mergePaths(basePath, rmFilePath); }
private Path createCollectorPath(Path filePath) { return mergePaths(filePath.getParent(), mergePaths(new Path(filePath.getName().split("\\.")[0]), mergePaths(new Path("_multipart"), new Path(Path.SEPARATOR)))); }
@Override public PartHandle putPart(Path filePath, InputStream inputStream, int partNumber, UploadHandle uploadId, long lengthInBytes) throws IOException { byte[] uploadIdByteArray = uploadId.toByteArray(); checkUploadId(uploadIdByteArray); Path collectorPath = new Path(new String(uploadIdByteArray, 0, uploadIdByteArray.length, Charsets.UTF_8)); Path partPath = mergePaths(collectorPath, mergePaths(new Path(Path.SEPARATOR), new Path(Integer.toString(partNumber) + ".part"))); try(FSDataOutputStream fsDataOutputStream = fs.createFile(partPath).build()) { IOUtils.copy(inputStream, fsDataOutputStream, 4096); } finally { org.apache.hadoop.io.IOUtils.cleanupWithLogger(LOG, inputStream); } return BBPartHandle.from(ByteBuffer.wrap( partPath.toString().getBytes(Charsets.UTF_8))); }
fs.create(filePath).close(); } else { Path filePathInsideCollector = mergePaths(collectorPath, new Path(Path.SEPARATOR + filePath.getName())); fs.create(filePathInsideCollector).close();
backupDataPath = new Path(scheme, authority, DEFAULT_BACKUP_PATH + filePath); } else { backupDataPath = Path.mergePaths(new Path(backup), inputPath);
private Path makeTrashRelativePath(Path basePath, Path rmFilePath) { return Path.mergePaths(basePath, rmFilePath); }
private Path makeTrashRelativePath(Path basePath, Path rmFilePath) { return Path.mergePaths(basePath, rmFilePath); }
private Path makeTrashRelativePath(Path basePath, Path rmFilePath) { return Path.mergePaths(basePath, rmFilePath); }
private Path makeTrashRelativePath(Path basePath, Path rmFilePath) { return Path.mergePaths(basePath, rmFilePath); }
private Path formatDataPath(String basePath) { return Path.mergePaths(new Path(basePath), new Path("/_record")); }
public static FileSelection createWithFullSchema(final FileSystemWrapper fs, final String parent, final String fullSchemaPath) throws IOException { final Path combined = Path.mergePaths(new Path(parent), PathUtils.toFSPath(fullSchemaPath)); return create(fs, combined); }
/** * Temporary location for file upload. * Add uuid so that this location remains unique even across file renames. * @param filePath file path in under home space * @param extension file extension * @return location of staging dir where user file is uploaded. */ private Path getStagingLocation(FilePath filePath, String extension) { FilePath uniquePath = filePath.rename(format("%s_%s-%s", filePath.getFileName().toString(), extension, UUID.randomUUID().toString())); return Path.mergePaths(config.getStagingPath(hostname), PathUtils.toFSPath(uniquePath.toPathList())); }
protected static void checkTrash(FileSystem trashFs, Path trashRoot, Path path) throws IOException { Path p = Path.mergePaths(trashRoot, path); assertTrue("Could not find file in trash: "+ p , trashFs.exists(p)); }
protected static void checkTrash(FileSystem trashFs, Path trashRoot, Path path) throws IOException { Path p = Path.mergePaths(trashRoot, path); assertTrue("Could not find file in trash: "+ p , trashFs.exists(p)); }
public static void assertDirectoriesInTrash(FileSystem fs, TrashPolicy trashPolicy, Path... dirs) throws IOException { Path trashDir = trashPolicy.getCurrentTrashDir(); for (Path path : dirs) { Path trashPath = Path.mergePaths(trashDir, fs.makeQualified(path)); assertTrue("Directory should exist in trash: " + trashPath, fs.exists(trashPath)); } } }
backupDataPath = new Path(scheme, authority, DEFAULT_BACKUP_PATH + filePath); } else { backupDataPath = Path.mergePaths(new Path(backup), corruptPath);
private Path getUploadLocation(FilePath filePath, String extension) { FilePath filePathWithExtension = filePath.rename(format("%s_%s", filePath.getFileName().getName(), extension)); return Path.mergePaths(config.getInnerUploads(), PathUtils.toFSPath(filePathWithExtension.toPathList())); }
@Test (timeout = 30000) public void testMergePaths() { assertEquals(new Path("/foo/bar"), Path.mergePaths(new Path("/foo"), new Path("/bar"))); assertEquals(new Path("/foo/bar/baz"), Path.mergePaths(new Path("/foo/bar"), new Path("/baz"))); assertEquals(new Path("/foo/bar/baz"), Path.mergePaths(new Path("/foo"), new Path("/bar/baz"))); assertEquals(new Path(Shell.WINDOWS ? "/C:/foo/bar" : "/C:/foo/C:/bar"), Path.mergePaths(new Path("/C:/foo"), new Path("/C:/bar"))); assertEquals(new Path(Shell.WINDOWS ? "/C:/bar" : "/C:/C:/bar"), Path.mergePaths(new Path("/C:/"), new Path("/C:/bar"))); assertEquals(new Path("/bar"), Path.mergePaths(new Path("/"), new Path("/bar"))); assertEquals(new Path("viewfs:///foo/bar"), Path.mergePaths(new Path("viewfs:///foo"), new Path("file:///bar"))); assertEquals(new Path("viewfs://vfsauthority/foo/bar"), Path.mergePaths(new Path("viewfs://vfsauthority/foo"), new Path("file://fileauthority/bar"))); }
@Test (timeout = 30000) public void testMergePaths() { assertEquals(new Path("/foo/bar"), Path.mergePaths(new Path("/foo"), new Path("/bar"))); assertEquals(new Path("/foo/bar/baz"), Path.mergePaths(new Path("/foo/bar"), new Path("/baz"))); assertEquals(new Path("/foo/bar/baz"), Path.mergePaths(new Path("/foo"), new Path("/bar/baz"))); assertEquals(new Path(Shell.WINDOWS ? "/C:/foo/bar" : "/C:/foo/C:/bar"), Path.mergePaths(new Path("/C:/foo"), new Path("/C:/bar"))); assertEquals(new Path(Shell.WINDOWS ? "/C:/bar" : "/C:/C:/bar"), Path.mergePaths(new Path("/C:/"), new Path("/C:/bar"))); assertEquals(new Path("/bar"), Path.mergePaths(new Path("/"), new Path("/bar"))); assertEquals(new Path("viewfs:///foo/bar"), Path.mergePaths(new Path("viewfs:///foo"), new Path("file:///bar"))); assertEquals(new Path("viewfs://vfsauthority/foo/bar"), Path.mergePaths(new Path("viewfs://vfsauthority/foo"), new Path("file://fileauthority/bar"))); }
Path trashDir = Path.mergePaths(new Path(trashRoot.toUri().getPath()), new Path(myFile.getParent().toUri().getPath()));