/** * Call {@link #mkdirs(Path, FsPermission)} with default permission. * @param f path * @return true if the directory was created * @throws IOException IO failure */ public boolean mkdirs(Path f) throws IOException { return mkdirs(f, FsPermission.getDirDefault()); }
@Override public UploadHandle initialize(Path filePath) throws IOException { Path collectorPath = createCollectorPath(filePath); fs.mkdirs(collectorPath, FsPermission.getDirDefault()); ByteBuffer byteBuffer = ByteBuffer.wrap( collectorPath.toString().getBytes(Charsets.UTF_8)); return BBUploadHandle.from(byteBuffer); }
CoreFileSystem fs = new CoreFileSystem(conf); fs.createWithPermissions(new Path(LLAP_PACKAGE_DIR), FsPermission.getDirDefault()); fs.copyLocalFileToHdfs(new File(packageDir.toString(), packageName), new Path(LLAP_PACKAGE_DIR), new FsPermission("755"));
FsPermission permission = FsPermission.getDirDefault().applyUMask(umask);
public FileStatus(long length, boolean isdir, int block_replication, long blocksize, long modification_time, long access_time, FsPermission permission, String owner, String group, Path symlink, Path path, Set<AttrFlags> attr) { this.length = length; this.isdir = isdir; this.block_replication = (short)block_replication; this.blocksize = blocksize; this.modification_time = modification_time; this.access_time = access_time; if (permission != null) { this.permission = permission; } else if (isdir) { this.permission = FsPermission.getDirDefault(); } else if (symlink != null) { this.permission = FsPermission.getDefault(); } else { this.permission = FsPermission.getFileDefault(); } this.owner = (owner == null) ? "" : owner; this.group = (group == null) ? "" : group; this.symlink = symlink; this.path = path; this.attr = attr; // The variables isdir and symlink indicate the type: // 1. isdir implies directory, in which case symlink must be null. // 2. !isdir implies a file or symlink, symlink != null implies a // symlink, otherwise it's a file. assert (isdir && symlink == null) || !isdir; }
/** * Convenience method, so that we don't open a new connection when using this * method from within another method. Otherwise every API invocation incurs * the overhead of opening/closing a TCP connection. */ private boolean mkdirs(FTPClient client, Path file, FsPermission permission) throws IOException { boolean created = true; Path workDir = new Path(client.printWorkingDirectory()); Path absolute = makeAbsolute(workDir, file); String pathName = absolute.getName(); if (!exists(client, absolute)) { Path parent = absolute.getParent(); created = (parent == null || mkdirs(client, parent, FsPermission .getDirDefault())); if (created) { String parentDir = parent.toUri().getPath(); client.changeWorkingDirectory(parentDir); created = created && client.makeDirectory(pathName); } } else if (isFile(client, absolute)) { throw new ParentNotDirectoryException(String.format( "Can't make directory for path %s since it is a file.", absolute)); } return created; }
protected boolean mkOneDirWithMode(Path p, File p2f, FsPermission permission) throws IOException { if (permission == null) { permission = FsPermission.getDirDefault(); } permission = permission.applyUMask(FsPermission.getUMask(getConf())); if (Shell.WINDOWS && NativeIO.isAvailable()) { try { NativeIO.Windows.createDirectoryWithMode(p2f, permission.toShort()); return true; } catch (IOException e) { if (LOG.isDebugEnabled()) { LOG.debug(String.format( "NativeIO.createDirectoryWithMode error, path = %s, mode = %o", p2f, permission.toShort()), e); } return false; } } else { boolean b = p2f.mkdir(); if (b) { setPermission(p, permission); } return b; } }
if (parent == null || !mkdirs(client, parent, FsPermission.getDirDefault())) { parent = (parent == null) ? new Path("/") : parent; disconnect(client);
final FsPermission absFerms = FsCreateModes.applyUMask( permission == null ? FsPermission.getDirDefault() : permission, getUMask()); new FSLinkResolver<Void>() { @Override
if (fs.isDirectory()) { checkDependencies(qSrc, qDst); mkdir(qDst, FsPermission.getDirDefault(), true); FileStatus[] contents = listStatus(qSrc); for (FileStatus content : contents) {
/** * Call {@link #mkdirs(Path, FsPermission)} with default permission. */ public boolean mkdirs(Path f) throws IOException { return mkdirs(f, FsPermission.getDirDefault()); }
/** * @return folder permission after applying umask */ @JsonIgnore public FsPermission getFolderPermission() { return FsPermission.getDirDefault().applyUMask(new FsPermission(umask)); }
File newFolder(TemporaryFolder basedir, String folder) { try { File newFolder = basedir.newFolder(folder); FileUtil.setPermission(newFolder, FsPermission.getDirDefault()); return newFolder; } catch (IOException e) { throw new IllegalStateException("Failed to create tmp dir: " + e.getMessage(), e); } }
/** * Create a directory and any nonexistent parents. Any portion * of the directory tree can exist without error. * Apply umask from conf * @param f The directory path to create * @return true if successful, false otherwise * @throws IOException if the path is a child of a file. */ @Override public boolean mkdirs(Path f) throws IOException { return mkdirs(f, FsPermission.getDirDefault().applyUMask(FsPermission.getUMask(getConf()))); }
@Test public void testMkdirsRoot() throws IOException { Path root = new Path("/"); assertTrue(fs.mkdirs(root, FsPermission.getDirDefault())); }
/** * Check that the constructor without owner, group and permissions works * correctly. */ @Test public void constructorNoOwner() throws IOException { boolean isdir = true; FileStatus fileStatus = new FileStatus(LENGTH, isdir, REPLICATION, BLKSIZE, MTIME, PATH); validateAccessors(fileStatus, LENGTH, isdir, REPLICATION, BLKSIZE, MTIME, 0, FsPermission.getDirDefault(), "", "", null, PATH); }
@Override public void doFault() throws Exception { fsWrapper.delete(zone1, true); fsWrapper.mkdir(zone1, FsPermission.getDirDefault(), true); dfsAdmin.createEncryptionZone(zone1, otherKey); } @Override
@Test public void testOnMessageIOException() throws IOException { try { getResponse(FsPermission.getDirDefault(), new IOException()); fail("Was expecting UserException/IOException"); } catch (UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(IOException.class, e.getCause().getClass()); } } }
@Test public void testOnMessageSuccessful() throws IOException { DFS.MkdirsResponse response = getResponse(FsPermission.getDirDefault(), true); assertEquals(true, response.getValue()); }
@Test public void testOnMessageSuccessful() throws IOException { TestRemoteIterator statuses = newRemoteIterator( new FileStatus(1337, false, 1, 4096, 1, 2, FsPermission.getFileDefault(), "testowner", "testgroup", new Path(TEST_PATH, "bar")), new FileStatus(0, true, 0, 0, 3, 4, FsPermission.getDirDefault(), "testowner", "testgroup", new Path(TEST_PATH, "baz")) ); DFS.ListStatusResponse response = getResponse(TEST_PATH_STRING, statuses); assertEquals(2, response.getStatusesList().size()); assertEquals(TEST_PATH_STRING + "/bar", response.getStatusesList().get(0).getPath()); assertEquals(TEST_PATH_STRING + "/baz", response.getStatusesList().get(1).getPath()); assertFalse(response.hasHandle()); assertTrue(statuses.isClosed()); }