AppserverIo\Appserver\Core\Utilities\FileSystem::createDirectory PHP Метод

createDirectory() публичный статический Метод

Creates the passed directory.
public static createDirectory ( string $directoryToCreate, integer $mode = 509, boolean $recursive = false ) : void
$directoryToCreate string The directory that should be created
$mode integer The mode to create the directory with
$recursive boolean TRUE if the directory has to be created recursively, else FALSE
Результат void
    public static function createDirectory($directoryToCreate, $mode = 0775, $recursive = false)
    {
        // we don't have a directory to change the user/group permissions for
        if (is_dir($directoryToCreate) === false) {
            // create the directory if necessary
            if (mkdir($directoryToCreate, $mode, $recursive) === false) {
                throw new \Exception(sprintf('Directory %s can\'t be created', $directoryToCreate));
            }
        }
    }

Usage Example

 /**
  * Creates the passed directory recursively with the umask specified in the system
  * configuration and sets the user permissions.
  *
  * @param \SplFileInfo $directoryToCreate The directory that should be created
  * @param integer      $mode              The mode to create the directory with
  * @param boolean      $recursively       TRUE if the directory has to be created recursively, else FALSE
  * @param string       $user              The user that has to own the passed directory
  * @param string       $group             The group that has to own the passed directory
  * @param integer      $umask             The new umask to set
  *
  * @return void
  * @throws \Exception Is thrown if the directory can't be created
  */
 public function createDirectory(\SplFileInfo $directoryToCreate, $mode = 0775, $recursively = true, $user = null, $group = null, $umask = null)
 {
     // set the umask that is necessary to create the directory
     $this->initUmask($umask);
     // create the directory itself
     FileSystem::createDirectory($directoryToCreate, $mode, $recursively);
     // load the deployment service
     $this->setUserRights($directoryToCreate, $user, $group);
 }