dir::make PHP Method

make() static public method

Creates a new directory
static public make ( string $dir ) : boolean
$dir string The path for the new directory
return boolean True: the dir has been created, false: creating failed
    static function make($dir)
    {
        if (is_dir($dir)) {
            return true;
        }
        if (!@mkdir($dir, 0755)) {
            return false;
        }
        @chmod($dir, 0755);
        return true;
    }

Usage Example

コード例 #1
0
ファイル: thumb.php プロジェクト: getkirby/toolkit
 /**
  * Constructor
  *
  * @param mixed $source
  * @param array $params
  */
 public function __construct($source, $params = array())
 {
     $this->source = $this->result = is_a($source, 'Media') ? $source : new Media($source);
     $this->options = array_merge(static::$defaults, $this->params($params));
     $this->destination = $this->destination();
     // don't create the thumbnail if it's not necessary
     if ($this->isObsolete()) {
         return;
     }
     // don't create the thumbnail if it exists
     if (!$this->isThere()) {
         // try to create the thumb folder if it is not there yet
         dir::make(dirname($this->destination->root));
         // check for a valid image
         if (!$this->source->exists() || $this->source->type() != 'image') {
             throw new Error('The given image is invalid', static::ERROR_INVALID_IMAGE);
         }
         // check for a valid driver
         if (!array_key_exists($this->options['driver'], static::$drivers)) {
             throw new Error('Invalid thumbnail driver', static::ERROR_INVALID_DRIVER);
         }
         // create the thumbnail
         $this->create();
         // check if creating the thumbnail failed
         if (!file_exists($this->destination->root)) {
             return;
         }
     }
     // create the result object
     $this->result = new Media($this->destination->root, $this->destination->url);
 }
All Usage Examples Of dir::make