當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FileHelper::createDirectory方法代碼示例

本文整理匯總了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;
 }
開發者ID:NetClearly,項目名稱:yii2-extensions,代碼行數:31,代碼來源:StaticAssetManager.php

示例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;
 }
開發者ID:timelessmemory,項目名稱:uhkklp,代碼行數:10,代碼來源:ExportSampleRecord.php

示例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;
 }
開發者ID:99designs,項目名稱:cabinet,代碼行數:13,代碼來源:FilesystemFileStore.php

示例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.');
         }
     }
 }
開發者ID:EugeneJk,項目名稱:yii2-custom-fields,代碼行數:15,代碼來源:ImageCropAction.php

示例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;
 }
開發者ID:jacmoe,項目名稱:yii2-mdpages-module,代碼行數:18,代碼來源:WikilinkTrait.php

示例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);
 }
開發者ID:aoyel,項目名稱:pinst,代碼行數:24,代碼來源:Connection.php


注:本文中的FileHelper::createDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。