/// <exception cref="System.IO.IOException"/> private void CreateDir(FileSystem fs, Path path, FsPermission fsPerm) { FsPermission dirPerm = new FsPermission(fsPerm); fs.Mkdirs(path, dirPerm); FsPermission umask = FsPermission.GetUMask(fs.GetConf()); if (!dirPerm.Equals(dirPerm.ApplyUMask(umask))) { fs.SetPermission(path, new FsPermission(fsPerm)); } }
/// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/> /// <exception cref="Org.Apache.Hadoop.FS.FileAlreadyExistsException"/> /// <exception cref="System.IO.FileNotFoundException"/> /// <exception cref="Org.Apache.Hadoop.FS.ParentNotDirectoryException"/> /// <exception cref="Org.Apache.Hadoop.FS.UnsupportedFileSystemException"/> /// <exception cref="System.IO.IOException"/> public override FSDataOutputStream Create(Path f, EnumSet <CreateFlag> createFlag, params Options.CreateOpts[] opts) { // Need to translate the FileContext-style options into FileSystem-style // Permissions with umask Options.CreateOpts.Perms permOpt = Options.CreateOpts.GetOpt <Options.CreateOpts.Perms >(opts); FsPermission umask = FsPermission.GetUMask(fs.GetConf()); FsPermission permission = (permOpt != null) ? permOpt.GetValue() : FsPermission.GetFileDefault ().ApplyUMask(umask); permission = permission.ApplyUMask(umask); // Overwrite bool overwrite = createFlag.Contains(CreateFlag.Overwrite); // bufferSize int bufferSize = fs.GetConf().GetInt(CommonConfigurationKeysPublic.IoFileBufferSizeKey , CommonConfigurationKeysPublic.IoFileBufferSizeDefault); Options.CreateOpts.BufferSize bufOpt = Options.CreateOpts.GetOpt <Options.CreateOpts.BufferSize >(opts); bufferSize = (bufOpt != null) ? bufOpt.GetValue() : bufferSize; // replication short replication = fs.GetDefaultReplication(f); Options.CreateOpts.ReplicationFactor repOpt = Options.CreateOpts.GetOpt <Options.CreateOpts.ReplicationFactor >(opts); replication = (repOpt != null) ? repOpt.GetValue() : replication; // blockSize long blockSize = fs.GetDefaultBlockSize(f); Options.CreateOpts.BlockSize blockOpt = Options.CreateOpts.GetOpt <Options.CreateOpts.BlockSize >(opts); blockSize = (blockOpt != null) ? blockOpt.GetValue() : blockSize; // Progressable Progressable progress = null; Options.CreateOpts.Progress progressOpt = Options.CreateOpts.GetOpt <Options.CreateOpts.Progress >(opts); progress = (progressOpt != null) ? progressOpt.GetValue() : progress; return(fs.Create(f, permission, overwrite, bufferSize, replication, blockSize, progress )); }