static INodesInPath resolvePathForStartFile(FSDirectory dir, FSPermissionChecker pc, String src, EnumSet<CreateFlag> flag, boolean createParent) throws IOException { INodesInPath iip = dir.resolvePath(pc, src, DirOp.CREATE); if (dir.isPermissionEnabled()) { dir.checkAncestorAccess(pc, iip, FsAction.WRITE); } INode inode = iip.getLastINode(); if (inode != null) { // Verify that the destination does not exist as a directory already. if (inode.isDirectory()) { throw new FileAlreadyExistsException(iip.getPath() + " already exists as a directory"); } // Verifies it's indeed a file and perms allow overwrite INodeFile.valueOf(inode, src); if (dir.isPermissionEnabled() && flag.contains(CreateFlag.OVERWRITE)) { dir.checkPathAccess(pc, iip, FsAction.WRITE); } } else { if (!createParent) { dir.verifyParentDir(iip); } if (!flag.contains(CreateFlag.CREATE)) { throw new FileNotFoundException("Can't overwrite non-existent " + src); } } return iip; }
fsd.checkAncestorAccess(pc, iip, FsAction.WRITE);
fsd.checkAncestorAccess(pc, iip, FsAction.WRITE);
if (lastINode == null) { if (fsd.isPermissionEnabled()) { fsd.checkAncestorAccess(pc, iip, FsAction.WRITE);
fsd.checkAncestorAccess(pc, iip, FsAction.WRITE);
if (lastINode == null) { if (fsd.isPermissionEnabled()) { fsd.checkAncestorAccess(pc, iip, FsAction.WRITE);
fsd.checkAncestorAccess(pc, iip, FsAction.WRITE);
dir.checkAncestorAccess(pc, iip, FsAction.WRITE);
dir.checkAncestorAccess(pc, iip, FsAction.WRITE);