/** * Find the parent of path that exists, if path does not exist * * @param fs * file system * @param path * @return FileStatus for argument path if it exists or the first ancestor in the path that exists * @throws IOException */ public static FileStatus getPathOrParentThatExists(FileSystem fs, Path path) throws IOException { FileStatus stat = FileUtils.getFileStatusOrNull(fs, path); if (stat != null) { return stat; } Path parentPath = path.getParent(); return getPathOrParentThatExists(fs, parentPath); }
boolean pickParent = (fileStatus == null); // did we find the file/dir itself? if (pickParent){ fileStatus = FileUtils.getPathOrParentThatExists(fs, filePath.getParent());
boolean pickParent = (fileStatus == null); // did we find the file/dir itself? if (pickParent){ fileStatus = FileUtils.getPathOrParentThatExists(fs, filePath.getParent());
/** * Find the parent of path that exists, if path does not exist * * @param fs * file system * @param path * @return FileStatus for argument path if it exists or the first ancestor in the path that exists * @throws IOException */ public static FileStatus getPathOrParentThatExists(FileSystem fs, Path path) throws IOException { FileStatus stat = FileUtils.getFileStatusOrNull(fs, path); if (stat != null) { return stat; } Path parentPath = path.getParent(); return getPathOrParentThatExists(fs, parentPath); }
/** * Find the parent of path that exists, if path does not exist * * @param fs * file system * @param path * @return FileStatus for argument path if it exists or the first ancestor in the path that exists * @throws IOException */ public static FileStatus getPathOrParentThatExists(FileSystem fs, Path path) throws IOException { FileStatus stat = FileUtils.getFileStatusOrNull(fs, path); if (stat != null) { return stat; } Path parentPath = path.getParent(); return getPathOrParentThatExists(fs, parentPath); }
try { fs = FileSystem.get(filePath.toUri(), conf); FileStatus fileStatus = FileUtils.getPathOrParentThatExists(fs, filePath); if (FileUtils.isOwnerOfFileHierarchy(fs, fileStatus, userName)) { availPrivs.addPrivilege(SQLPrivTypeGrant.OWNER_PRIV);