CHMOD a directory.

@param string $pDir
@param mixed $pMode
@return bool
16318
public static function chmod($pDir, $pMode)
    {
        if (strpos($pMode, '0') !== 0) {
            $mode = octdec('0' . $pMode);
        } else {
            $mode = octdec($pMode);
        }

        return chmod($pDir, $mode);
    }
6933
public static function create($dir, $chmod = null)
    {
        if (!file_exists($dir)) {
            if ($chmod === null) {
                $chmod = self::$defaultChmod;
            }
            mkdir($dir, $chmod, true);
            // php mkdir apply umask on the given mode, so we must to
            // do a chmod manually.
            chmod($dir, $chmod);
            return true;
        }

        return false;
    }
745465
public void setSystemPropertiesMode(String pMode) {
        systemPropertyMode = SystemPropertyMode.fromMode(pMode);
        if (systemPropertyMode == null) {
            systemPropertyMode = SystemPropertyMode.MODE_NEVER;
        }
    }
603453
protected static function chmod($filename, $perm, $add): bool
    {
        return chmod($filename, (fileperms($filename) | intval('0' . $perm . $perm . $perm, 8)) ^ $add);
    }
974626
protected function chmodReal($filename, $mode)
    {
        try {
            $result = @chmod($filename, $mode);
        } catch (\Exception $e) {
            $result = false;
        }

        if (!$result) {
            $this->chown($filename, $this->getDefaultOwner(true));
            $this->chgrp($filename, $this->getDefaultGroup(true));

            try {
                $result = @chmod($filename, $mode);
            } catch (\Exception $e) {
                throw new Error($e->getMessage());
            }
        }

        return $result;
    }
1065498
public function mkdir(string $directory, int $mode = null): bool {
    if (!empty($directory)) {
      if ($folders = explode(DIRECTORY_SEPARATOR, Path::replaceOSSeparator($directory))) {
        $fullpath = null;
        if (empty($mode)) {
          $mode = AccessMode::MOD_0777;
        }
        foreach ($folders as $folder) {
          if (!empty($folder)) {
            $fullpath .= DIRECTORY_SEPARATOR . $folder;
            $this->createDirectory($fullpath, $mode);
          }
        }
      }
    }
    return file_exists($directory);
  }
417023
private function chmod(string $path, int $mode): bool
    {
        if (!@chmod($path, $mode)) {
            $message = 'Could not change file mode.';
            if ($error = error_get_last()) {
                $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']);
            }
            throw new FileException($message);
        }

        return true;
    }
260946
def safe_chmod(path, mode):
    
    if stat.S_IMODE(os.stat(path).st_mode) != mode:
        os.chmod(path, mode)
329717
def safeMkdir(p, permissions = permissions755):
	''''''
	try:
		os.mkdir(p)
	except OSError:
		pass
	os.chmod(p, permissions)
1313582
public function mkdir($dir_name, $mode = 0755)
    {
        if (is_dir($dir_name)) {
            chmod($dir_name, $mode);

            return true;
        }

        return mkdir($dir_name, $mode, true);
    }
128330
def chdir(directory):
    
    directory = os.path.abspath(directory)
    logger.info("chdir -> %s" % directory)
    try:
        if not os.path.isdir(directory):
            logger.error(
                "chdir -> %s failed! Directory does not exist!", directory
            )
            return False
        os.chdir(directory)
        return True
    except Exception as e:
        logger.error("chdir -> %s failed! %s" % (directory, e))
        return False
1255177
public static function mkdir($path, $chmod = 0777)
    {
        if (true === file_exists($path)) {
            return true;
        }

        $path = explode(DIRECTORY_SEPARATOR, $path);
        $folderCount = count($path);


        for ($folderIndex = 1; $folderIndex <= $folderCount; $folderIndex++) {
            $subFolder = implode(DIRECTORY_SEPARATOR, array_slice($path, 0, $folderIndex));

            if (true === empty($subFolder)) {
                continue;
            }

            if (true === file_exists($subFolder)) {
                continue;
            }

            if (false === mkdir($subFolder, $chmod, true)) {
                return false;
            }

            chmod($subFolder, 0777);
        }

        return true;
    }
372036
public static function chmod(
        $path = null, $mode = self::DEFAULT_UNIX_CHMOD_DIRECTORIES,
        $recursive = true, $file_mode = self::DEFAULT_UNIX_CHMOD_FILES, array &$logs = array()
    ){
        if (is_null($path)) {
            return null;
        }
        $ok = false;
        if (file_exists($path) && is_dir($path)) {
            if (true!==($ok = chmod($path, Filesystem::getOctal($mode)))) {
                $logs[] = sprintf('Can not change mode on directory "%s" (trying to set them on "%d").', $path, $mode);
            }
            if ($ok && true===$recursive) {
                $iterator = new \RecursiveIteratorIterator(
                    new \RecursiveDirectoryIterator($path), 
                    \RecursiveIteratorIterator::SELF_FIRST | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS
                );
                foreach($iterator as $item) {
                    if (in_array($item->getFilename(), array('.', '..'))) {
                        continue;
                    }
                    if ($item->isDir()) {
                        if (true!==($ok = chmod($item, Filesystem::getOctal($mode)))) {
                            $logs[] = sprintf('Can not change mode on sub-directory "%s" (trying to set them on "%d").', $item, $mode);
                        }
                    } elseif ($item->isFile() && !$item->isLink()) {
                        if (true!==($ok = chmod($item, Filesystem::getOctal($file_mode)))) {
                            $logs[] = sprintf('Can not change mode on file "%s" (trying to set them on "%d").', $item, $file_mode);
                        }
                    }
                } 
            }
            clearstatcache();
        } else {
            $logs[] = sprintf('Directory "%s" not found (can not change mode).', $path);
        }
        return $ok;
    }
342302
public static function create($path, $chmod = 0755)
    {
        $path = Normalize::diskFullPath($path);

        if (self::exist($path)) {
            return false;
        }

        return @mkdir($path, $chmod, true);
    }
217643
def fs_chmod(mode, file = '/')
      FileUtils.chmod_R(mode, File.join(self.git_dir, file))
    end
995004
def chmod(self, mode):
        
        if self._closed:
            self._raise_closed()
        self._accessor.chmod(self, mode)
1081528
public function chmodR($path, $filemode)
    {

        if (!$this->isFolder($path)) {
            return $this->chmod($path, $filemode);
        }

        $dirh = @opendir($path);
        while ($file = readdir($dirh)) {
            if ($file != '.' && $file != '..') {
                $fullpath = $path . '/' . $file;
                if (!$this->isFolder($fullpath)) {
                    if (!$this->chmod($fullpath, $filemode)) {
                        return false;
                    }
                } else {
                    if (!$this->chmodR($fullpath, $filemode)) {
                        return false;
                    }
                }
            }
        }

        closedir($dirh);

        if ($this->chmod($path, $filemode)) {
            return true;
        } else {
            return false;
        }
    }