创建缓存依赖文件

@return bool|string
329516
public function createFile()
    {
        $cacheDependencyFileName = $this->getDependencyFileName();
        if ( ! file_exists(dirname($cacheDependencyFileName)) ) {
            FileHelper::createDirectory(dirname($cacheDependencyFileName));
        }
        file_put_contents($cacheDependencyFileName, uniqid());
        return $cacheDependencyFileName;
    }
175849
public function getFilename()
	{
		if (is_null($this->filename)) {
			$this->filename = pathinfo($this->path, PATHINFO_BASENAME);
		}
		return $this->filename;
	}
1311002
public function getFilepath()
    {
        $filepath = $this->_path['dirname'].DIRECTORY_SEPARATOR.$this->_path['filename'];

        if ($this->_path['extension'])
            $filepath .= '.'.$this->_path['extension'];

        return $filepath;
    }
742646
public function info()
    {
        if (!$this->info) {
            $this->info = pathinfo($this->path);
        }
        if (!isset($this->info['filename'])) {
            $this->info['filename'] = $this->name();
        }
        if (!isset($this->info['filesize'])) {
            $this->info['filesize'] = $this->size();
        }
        if (!isset($this->info['mime'])) {
            $this->info['mime'] = $this->mime();
        }

        return $this->info;
    }
86928
public function upload()
    {
      if ($this->error !== '') {
        return false;
      }

      $isValid = $this->contraintsValidator();

      $isSuccess = $isValid && $this->isSaved($this->_files['tmp_name'], $this->getFullPath());

      return $isSuccess ? $this : false;
    }
32307
protected function getFile()
    {
        $path = $this->directory.'/'.self::MANIFEST_FILENAME;
        $file = $this->pathHelper->getPublicPath($path, true);
        return $file;
    }
1317658
public function contents()
	{
		if ($this->declaration)
		{
			return $this->name;
		}

		return file_exists($this->targetPath()) ? file_get_contents($this->targetPath()) : '';
	}
1073313
public function getPath()
	{
		$realpath	= realpath( $this->fileName );
		$path	= dirname( $realpath );
		$path	= str_replace( "\\", "/", $path );
		$path	.= "/";
		return	$path;
	}
511802
public function upFile()
    {
        $file = UploadedFile::getInstanceByName($this->fileField);
        $validator = new FileValidator($this->config);
        if ($validator->validate($file, $error)) {
            //设置文件名称
            $this->oriName = $file->name;
            //设置文件大小
            $this->fileSize = $file->size;
            $this->fileType = $this->getExtension();
            $this->fullName = $this->getFullName();
            $this->filePath = $this->getFilePath();
            $this->fileName = $this->getFileName();
            $dirName = dirname($this->filePath);
            if (!is_dir($dirName)) {//递归创建保存目录
                FileHelper::createDirectory($dirName, $this->dirMode, true);
            }
            if (!($file->saveAs($this->filePath) && file_exists($this->filePath))) {
                $this->stateInfo = Yii::t('attachment', 'An error occurred while saving the file.');
                return false;
            } else { //移动成功
                $this->saveModel();
                $this->stateInfo = 'SUCCESS';
                return true;
            }
        }
        return false;
    }
68196
public function getMediumPath() {

		if( isset( $this->medium ) ) {

			return Yii::$app->fileManager->uploadDir . '/' . $this->medium;
		}

		return false;
	}
680362
public function upload($files = '')
    {
        if ('' === $files) {
            $files = $_FILES;
        }
        if (empty($files)) {
            $this->error = '没有上传的文件！';

            return false;
        }
        /* 检测上传根目录 */
        if (!$this->uploader->checkRootPath($this->rootPath)) {
            $this->error = $this->uploader->getError();

            return false;
        }
        /* 检查上传目录 */
        if (!$this->uploader->checkSavePath($this->savePath)) {
            $this->error = $this->uploader->getError();

            return false;
        }
        /* 逐个检测并上传文件 */
        $info = [];
        if (function_exists('finfo_open')) {
            $finfo = finfo_open(FILEINFO_MIME_TYPE);
        }
        // 对上传文件数组信息处理
        $files = $this->dealFiles($files);
        foreach ($files as $key => $file) {
            $file['name'] = strip_tags($file['name']);
            if (!isset($file['key'])) {
                $file['key'] = $key;
            }
            /* 通过扩展获取文件类型，可解决FLASH上传$FILES数组返回文件类型错误的问题 */
            if (isset($finfo)) {
                $file['type'] = finfo_file($finfo, $file['tmp_name']);
            }
            /* 获取上传文件后缀，允许上传无后缀文件 */
            $file['ext'] = pathinfo($file['name'], PATHINFO_EXTENSION);
            /* 文件上传检测 */
            if (!$this->check($file)) {
                continue;
            }
            /* 获取文件hash */
            if ($this->hash) {
                $file['md5'] = md5_file($file['tmp_name']);
                $file['sha1'] = sha1_file($file['tmp_name']);
            }
            /* 调用回调函数检测文件是否存在 */
            if ($this->callback) {
                $data = call_user_func($this->callback, $file);
            }
            if ($this->callback && $data) {
                if (file_exists('.' . $data['path'])) {
                    $info[$key] = $data;
                    continue;
                } elseif ($this->removeTrash) {
                    call_user_func($this->removeTrash, $data); //删除垃圾据
                }
            }
            /* 生成保存文件名 */
            $savename = $this->getSaveName($file);
            if (false == $savename) {
                continue;
            } else {
                $file['savename'] = $savename;
            }
            /* 检测并创建子目录 */
            $subpath = $this->getSubPath($file['name']);
            if (false === $subpath) {
                continue;
            } else {
                $file['savepath'] = $this->savePath . $subpath;
            }
            /* 对图像文件进行严格检测 */
            $ext = strtolower($file['ext']);
            if (in_array($ext, ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf'])) {
                $imginfo = getimagesize($file['tmp_name']);
                if (empty($imginfo) || ('gif' == $ext && empty($imginfo['bits']))) {
                    $this->error = '非法图像文件！';
                    continue;
                }
            }
            /* 保存文件 并记录保存成功的文件 */
            if ($this->uploader->save($file, $this->replace)) {
                unset($file['error'], $file['tmp_name']);
                $info[$key] = $file;
            } else {
                $this->error = $this->uploader->getError();
            }
        }
        if (isset($finfo)) {
            finfo_close($finfo);
        }

        return empty($info) ? false : $info;
    }
1088890
protected function _getFromFile()
    {
        $file = new File($this->params['source']);
        if ($this->_unzip($file->pwd())) {
            return $this->_validateContent();
        }

        $this->err(__d('installer', 'Unable to extract the package.'));

        return false;
    }
699594
private function moveFile()
        {
            $files = $this->files;
            
            if ($this->formats != "" && !in_array($this->fileExt, $this->formats))
            {
                $formats = implode(',', $this->formats);
                $message = "您上传的文件" . $files["name"] . "是" . $this->fileExt . "格式的，系统不允许上传，您只能上传" . $formats . "格式的文件。";
                $this->message($message);
                
                return false;
            }

            if ($files["size"] / 1024 > $this->maxSize)
            {
                $message = "您上传的 " . $files["name"] . "，文件大小超出了系统限定值" . $this->maxSize . " KB，不能上传。";
                $this->message($message);
                
                return false;
            }

            if (!$this->cover) //当不能覆盖时
            {
                if(file_exists($this->savePath.$this->saveName)) //有相同的文件存在
                {
                    $this->message($this->saveName . $this->errors['same_file']);
                    
                    return false;
                }
            }

            if (!@move_uploaded_file($files["tmp_name"], iconv("utf-8", "gbk", $this->savePath . $this->saveName)))
            {                
                switch($files["errors"])
                {
                    case '0':
                        $message = "文件上传成功";
                        break;
                    
                    case '1':
                        $message = "上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值";
                        break;
                    
                    case '2':
                        $message = "上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值";
                        break;
                    
                    case '3':
                        $message = "文件只有部分被上传";
                        break;
                    
                    case '4':
                        $message = "没有文件被上传";
                        break;
                    
                    case '6':
                        $message = "找不到临时目录";
                        break;
                    
                    case '7':
                        $message = "写文件到硬盘时出错";
                        break;
                    
                    case '8':
                        $message = "某个扩展停止了文件的上传";
                        break;
                    
                    case '999':
                    default:
                        $message = "未知错误，请检查文件是否损坏、是否超大等原因。";
                        break;
                }

                $this->message($message);
                
                return false;
            }
            
            @unlink($files["tmp_name"]); //删除临时文件
            
            return true;
        }
68323
public function path(){

        $args = \func_get_args();

        switch (\count($args)){

            case 1:

                $file  = $args[0];

                if ($this->isAbsolutePath($file) && \file_exists($file)) {
                    return $file;
                }

                $parts = \explode(':', $file, 2);

                if (count($parts)==2){
                    if (!isset($this->paths[$parts[0]])) return false;

                    foreach ($this->paths[$parts[0]] as &$path){
                        if (\file_exists($path.$parts[1])){
                            return $path.$parts[1];
                        }
                    }
                }

                return false;

            case 2:

                if (!isset($this->paths[$args[0]])) {
                    $this->paths[$args[0]] = [];
                }
                \array_unshift($this->paths[$args[0]], \rtrim(\str_replace(DIRECTORY_SEPARATOR, '/', $args[1]), '/').'/');

                return $this;
        }

        return null;
    }
745255
public function getFile()
    {
        $key = $this->getKey();

        $tags = $this->getTags();

        if (!$this->cache->has($key, $tags)) {
            $this->loadFile();
        }

        return simplexml_load_string($this->cache->get($key, $tags));
    }
317599
public function getPath()
    {
        $path = !empty($this->info['path']) ? '/'.implode('/', $this->info['path']).'/' : '/';

        if (!empty($this->info['file'])) {
            $path .= $this->info['file'];

            if (!empty($this->info['extension'])) {
                $path .= '.'.$this->info['extension'];
            }
        }

        return $path;
    }
1281021
public function update()
        {
                $ok = true;

                // perform updates...
                $ok = $this->updateFile(self::FILENAME_RULES);

                if ($ok)
                        $ok = $this->updateFile(self::FILENAME_CONVERTER);

                return $ok;
        }