本文整理汇总了PHP中FileHelper::createDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHelper::createDirectory方法的具体用法?PHP FileHelper::createDirectory怎么用?PHP FileHelper::createDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelper
的用法示例。
在下文中一共展示了FileHelper::createDirectory方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publishFile
/**
* Publishes a file.
* @param string $src the asset file to be published
* @return array the path and the URL that the asset is published as.
* @throws InvalidParamException if the asset to be published does not exist.
*/
protected function publishFile($src)
{
\Yii::trace("src:{$src} ", __METHOD__);
$dir = $this->hash($src);
$fileName = basename($src);
$dstDir = $this->basePath . DIRECTORY_SEPARATOR . $dir;
$dstFile = $dstDir . DIRECTORY_SEPARATOR . $fileName;
\Yii::trace("dstFile:{$dstFile} ", __METHOD__);
if (!is_dir($dstDir)) {
FileHelper::createDirectory($dstDir, $this->dirMode, true);
}
if ($this->linkAssets) {
if (!is_file($dstFile)) {
symlink($src, $dstFile);
}
} elseif (@filemtime($dstFile) < @filemtime($src)) {
copy($src, $dstFile);
if ($this->fileMode !== null) {
@chmod($dstFile, $this->fileMode);
}
}
$result = [$dstFile, $this->baseUrl . "/{$dir}/{$fileName}"];
\Yii::trace("result:{$result} ", __METHOD__);
return $result;
}
示例2: getFile
public static function getFile($fileName, $fileType = 'csv')
{
//make sure the file name is unqiue
$fileName = Yii::$app->getRuntimePath() . '/temp/' . $fileName . '.' . strtolower($fileType);
$filePath = dirname($fileName);
if (!is_dir($filePath)) {
FileHelper::createDirectory($filePath, 0777, true);
}
return $fileName;
}
示例3: _getRealFilePath
/**
* Generate the actual filesystem path for a filekey
*/
protected function _getRealFilePath($filekey, $createDir = true)
{
$filekey = substr(sha1($filekey), 0, 32);
$path = sprintf('%s/%s/', rtrim($this->_filepath, '/'), substr($filekey, 0, self::STUB_KEY_LENGTH));
// ensure directory path exists
if ($createDir && !is_dir($path)) {
FileHelper::createDirectory($path);
}
return $path . $filekey;
}
示例4: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!$this->uploadRootPath) {
throw new InvalidConfigException('The "savePath" attribute must be set.');
} else {
$this->uploadRootPath = rtrim(Yii::getAlias($this->uploadRootPath), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
if (!file_exists($this->uploadRootPath) && !FileHelper::createDirectory($this->uploadRootPath)) {
throw new InvalidCallException('Directory specified in "savePath" attribute doesn\'t exist or cannot be created.');
}
}
}
示例5: getFlywheelRepo
/**
*
* @return \JamesMoss\Flywheel\Repository
*/
private function getFlywheelRepo($module)
{
if (!isset($this->flywheel_config)) {
$config_dir = \Yii::getAlias($module->flywheel_config);
if (!file_exists($config_dir)) {
FileHelper::createDirectory($config_dir);
}
$this->flywheel_config = new Config($config_dir);
}
if (!isset($this->flywheel_repo)) {
$this->flywheel_repo = new Repository($module->flywheel_repo, $this->flywheel_config);
}
return $this->flywheel_repo;
}
示例6: store
/**
* store cht log
* @param null $filename filename
* @return bool
* @throws \pinst\exception\ExitException
*/
public function store($filename = null)
{
if (empty($filename)) {
$filename = \Pinst::$app->runtimePath . DIRECTORY_SEPARATOR . "msg";
if (!is_dir($filename)) {
FileHelper::createDirectory($filename);
}
}
$filename .= DIRECTORY_SEPARATOR . $this->getProperty("client_id") . '_' . time();
$fp = fopen($filename, "a+");
if (!$fp) {
return false;
}
foreach ($this->message as $msg) {
fwrite($fp, '[' . date("Y/m/d H:i:s", $msg['time']) . ']' . $msg['content']);
}
fclose($fp);
}