This commit is contained in:
cuiliang
2016-03-02 18:50:50 +08:00
707 changed files with 52230 additions and 4 deletions

View File

@@ -258,7 +258,11 @@ class BaseFileHelper
$handle = opendir($src);
if ($handle === false) {
<<<<<<< HEAD
throw new InvalidParamException('Unable to open directory: ' . $src);
=======
throw new InvalidParamException("Unable to open directory: $src");
>>>>>>> yiichina/master
}
if (!isset($options['basePath'])) {
// this should be done only once
@@ -365,7 +369,11 @@ class BaseFileHelper
public static function findFiles($dir, $options = [])
{
if (!is_dir($dir)) {
<<<<<<< HEAD
throw new InvalidParamException('The dir argument must be a directory.');
=======
throw new InvalidParamException("The dir argument must be a directory: $dir");
>>>>>>> yiichina/master
}
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
if (!isset($options['basePath'])) {
@@ -376,7 +384,11 @@ class BaseFileHelper
$list = [];
$handle = opendir($dir);
if ($handle === false) {
<<<<<<< HEAD
throw new InvalidParamException('Unable to open directory: ' . $dir);
=======
throw new InvalidParamException("Unable to open directory: $dir");
>>>>>>> yiichina/master
}
while (($file = readdir($handle)) !== false) {
if ($file === '.' || $file === '..') {
@@ -447,6 +459,10 @@ 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
<<<<<<< HEAD
=======
* @throws \yii\base\Exception if the directory could not be created.
>>>>>>> yiichina/master
*/
public static function createDirectory($path, $mode = 0775, $recursive = true)
{
@@ -457,8 +473,17 @@ class BaseFileHelper
if ($recursive && !is_dir($parentDir)) {
static::createDirectory($parentDir, $mode, true);
}
<<<<<<< HEAD
$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);
}
>>>>>>> yiichina/master
return $result;
}