mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 04:37:42 +08:00
Merge branch 'improved-mkdir-error'
Conflicts: framework/CHANGELOG.md
This commit is contained in:
@ -447,6 +447,7 @@ class BaseFileHelper
|
||||
* @param integer $mode the permission to be set for the created directory.
|
||||
* @param boolean $recursive whether to create parent directories if they do not exist.
|
||||
* @return boolean whether the directory is created successfully
|
||||
* @throws \yii\base\Exception if the directory could not be created.
|
||||
*/
|
||||
public static function createDirectory($path, $mode = 0775, $recursive = true)
|
||||
{
|
||||
@ -457,8 +458,12 @@ class BaseFileHelper
|
||||
if ($recursive && !is_dir($parentDir)) {
|
||||
static::createDirectory($parentDir, $mode, true);
|
||||
}
|
||||
$result = mkdir($path, $mode);
|
||||
chmod($path, $mode);
|
||||
try {
|
||||
$result = mkdir($path, $mode);
|
||||
chmod($path, $mode);
|
||||
} catch(\Exception $e) {
|
||||
throw new \yii\base\Exception("Failed to create directory '$path': " . $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user