改名
This commit is contained in:
+7
-7
@@ -43,11 +43,11 @@ if (!function_exists('storage')) {
|
||||
function storage($fileName = '', $path = '')
|
||||
{
|
||||
$basePath = Snowflake::getStoragePath();
|
||||
// if (empty($path)) {
|
||||
// return $basePath . '/' . $fileName;
|
||||
// } else if (empty($fileName)) {
|
||||
// return initDir($basePath, $path);
|
||||
// }
|
||||
if (empty($path)) {
|
||||
return $basePath . '/' . $fileName;
|
||||
} else if (empty($fileName)) {
|
||||
return initDir($basePath, $path);
|
||||
}
|
||||
return initDir($basePath, $path) . $fileName;
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ if (!function_exists('storage')) {
|
||||
foreach ($explode as $value) {
|
||||
$path .= $value . '/';
|
||||
if (!is_dir($basePath . $path)) {
|
||||
// mkdir($basePath . $path);
|
||||
mkdir($basePath . $path);
|
||||
}
|
||||
if (!is_dir($basePath . $path)) {
|
||||
// throw new Exception('System error, directory ' . $basePath . $path . ' is not writable');
|
||||
throw new Exception('System error, directory ' . $basePath . $path . ' is not writable');
|
||||
}
|
||||
}
|
||||
return realpath($basePath . $path);
|
||||
|
||||
@@ -20,6 +20,7 @@ use Snowflake\Di\Service;
|
||||
use Snowflake\Error\ErrorHandler;
|
||||
use Snowflake\Error\Logger;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Snowflake\Exception\InitException;
|
||||
use Snowflake\Pool\Connection;
|
||||
use Snowflake\Pool\RedisClient;
|
||||
use Snowflake\Processes;
|
||||
@@ -142,45 +143,17 @@ abstract class BaseApplication extends Service
|
||||
foreach ($config as $key => $value) {
|
||||
Config::set($key, $value);
|
||||
}
|
||||
// if (isset($config['id'])) {
|
||||
// $this->id = $config['id'];
|
||||
// unset($config['id']);
|
||||
// }
|
||||
// if (isset($config['storage'])) {
|
||||
// $this->storage = $config['storage'];
|
||||
// unset($config['storage']);
|
||||
// }
|
||||
// if (!empty($this->runtimePath)) {
|
||||
// if (!is_dir($this->runtimePath)) {
|
||||
// mkdir($this->runtimePath, 777);
|
||||
// }
|
||||
//
|
||||
// if (!is_dir($this->runtimePath) || !is_writeable($this->runtimePath)) {
|
||||
// throw new InitException("Directory {$this->runtimePath} does not have write permission");
|
||||
// }
|
||||
// }
|
||||
// if (isset($config['aliases'])) {
|
||||
// $this->classAlias($config);
|
||||
// }
|
||||
//
|
||||
// foreach ($this->moreComponents() as $key => $val) {
|
||||
// if (isset($config['components'][$key])) {
|
||||
// $config['components'][$key] = array_merge($val, $config['components'][$key]);
|
||||
// } else {
|
||||
// $config['components'][$key] = $val;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
private function classAlias(array &$data)
|
||||
{
|
||||
foreach ($data['aliases'] as $key => $val) {
|
||||
class_alias($val, $key, true);
|
||||
if ($storage = Config::get('storage', false, 'storage')) {
|
||||
if (strpos($storage, APP_PATH) === false) {
|
||||
$storage = realpath(APP_PATH . $storage);
|
||||
}
|
||||
if (!is_dir($storage)) {
|
||||
mkdir($storage, 777);
|
||||
}
|
||||
if (!is_dir($storage) || !is_writeable($storage)) {
|
||||
throw new InitException("Directory {$storage} does not have write permission");
|
||||
}
|
||||
}
|
||||
unset($data['aliases']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class Snowflake
|
||||
{
|
||||
$path = realpath(static::$service->storage);
|
||||
if (!is_dir($path)) {
|
||||
// mkdir($path);
|
||||
mkdir($path);
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
@@ -128,11 +128,11 @@ class Snowflake
|
||||
public static function writeFile($fileName, $content, $is_append = FILE_APPEND)
|
||||
{
|
||||
return false;
|
||||
// if (self::inCoroutine()) {
|
||||
// return Coroutine::writeFile($fileName, $content, $is_append);
|
||||
// } else {
|
||||
// return file_put_contents($fileName, $content, $is_append);
|
||||
// }
|
||||
if (self::inCoroutine()) {
|
||||
return Coroutine::writeFile($fileName, $content, $is_append);
|
||||
} else {
|
||||
return file_put_contents($fileName, $content, $is_append);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user