获取配置文件的路径

@param string $sName 配置的命名空间
@static
@access public
@return array
518687
public static function getFile($sName) {
		$sFile        =& static::$_lFile[$sName];
		$sFileDefault =& static::$_lFileDefault[$sName];
		return [
			'file' => $sFile,
			'file_default' => $sFileDefault,
		];
	}
9337
public function getFileByName($filename)
    {
        $files = $this->getFiles();
        foreach ($files as $file) {
            if ($filename == $file->file) {
                return $file;
            }
        }

        return null;
    }
1373655
public static function getFileContentType($filename)
    {
        $path_parts = pathinfo($filename);//返回文件路径的信息
        $ext = strtolower($path_parts["extension"]); //将字符串转化为小写
        // Determine Content Type
        switch ($ext) {
            case "ico":
                $cType = "image/x-icon";
                break;
            case "pdf":
                $cType = "application/pdf";
                break;
            case "exe":
                $cType = "application/octet-stream";
                break;
            case "zip":
                $cType = "application/zip";
                break;
            case "doc":
                $cType = "application/msword";
                break;
            case "xls":
            case "xlsx":
                $cType = "application/vnd.ms-excel";
                break;
            case "ppt":
                $cType = "application/vnd.ms-powerpoint";
                break;
            case "gif":
                $cType = "image/gif";
                break;
            case "png":
                $cType = "image/png";
                break;
            case "jpeg":
            case "jpg":
                $cType = "image/jpg";
                break;
            case "css":
                $cType = "text/css";
                break;
            case "js":
                $cType = "text/x-javascript";
                break;
            case "html":
                $cType = "text/html";
                break;
            case "txt":
            case "xml":
                $cType = "text/xml";
                break;
            default:
                $cType = "application/force-download";
                break;
        }

//        header("Pragma", "public"); // required 指明响应可被任何缓存保存
//        header("Expires", "0");
//        header("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
//        header("Content-Type", $ctype);
        return $cType;
    }
852927
public static function get( $name = '' ) {
		$name = self::sanitize( $name );
		$filename = self::get_filename( $name );

		return $filename ? @file_get_contents( $filename ) : '';
	}
1114454
public function getUniqueFilename($filename)
    {
        $info = pathinfo($filename);
        $name = $info['filename'];
        $ext = isset($info['extension']) ? '.'.$info['extension'] : '';
        for ($i = 1; file_exists($info['dirname'].'/'.$name.$ext); ++$i) {
            $name = $info['filename'].'['.$i.']';
        }

        return $info['dirname'].'/'.$name.$ext;
    }
1309987
public function getNamesWithDifferentExtension(string $fileName)
    {
        if (! file_exists($this->basePath)) {
            return [];
        }

        $extension = pathinfo($fileName, PATHINFO_EXTENSION);

        $baseName = substr($fileName, 0, strlen($fileName) - strlen($extension) - 1);

        $allNames = scandir($this->basePath);

        $namesWithDifferentExtension = array_filter($allNames, function ($existingName) use ($baseName, $extension) {
            $existingExtension = pathinfo($existingName, PATHINFO_EXTENSION);

            $existingBaseName = substr($existingName, 0, strlen($existingName) - strlen($existingExtension) - 1);

            return $existingBaseName === $baseName && $existingExtension !== $extension;
        });

        return array_values($namesWithDifferentExtension);
    }
424970
private function getFile(string $key): array
    {
        if (!preg_match('/^\w+$/', $key)) {
            $key = md5($key);
        }

        // 返回唯一Key,缓存内容的文件名,缓存语句的文件名
        return [$key, $this->path() . $key . '.cache', $this->path() . $key . '.sql'];
    }
161656
private function getDirs($fileName)
    {
        if (is_file($fileName)) {
            return [];
        }

        $currentDir = getcwd();

        if (is_dir($fileName)) {
            $currentDir = $fileName;
        }

        $dirs[] = $currentDir;
        if (is_dir($currentDir.'/conf')) {
            $dirs[] = $currentDir.'/conf';
        }
        if (is_dir($currentDir.'/config')) {
            $dirs[] = $currentDir.'/config';
        }

        return $dirs;
    }
129662
public static function getFileInfo($filename)
    {
        if (!is_file($filename)) {
            return false;
        }
        return [
            'atime' => date("Y-m-d H:i:s", fileatime($filename)),
            'ctime' => date("Y-m-d H:i:s", filectime($filename)),
            'mtime' => date("Y-m-d H:i:s", filemtime($filename)),
            'size'  => filesize($filename),
            'type'  => filetype($filename)
        ];
    }
23836
static function read($name)
    {
        if (!isset(self::$loaded[$name])) {
            self::$loaded[$name] = [];
            foreach (self::$dirs as $dir) {
                try {
                    $c = include $dir . $name . '.php';
                    self::$loaded[$name] = array_merge_recursive(self::$loaded[$name], $c);
                } catch (\Exception $e) {
                }
            }
        }
        return self::$loaded[$name];
    }
1248089
protected function loadFromCache(string $fileName): array
    {
        $content     = file_get_contents($fileName);
        $loadedItems = unserialize($content);

        return $loadedItems;
    }
152322
private static function loadFileOrEmpty($filename)
    {
        if (!file_exists($filename)) {
            return [];
        }

        try {
            if (!is_array($content = Yaml::parse(file_get_contents($filename)))) {
                $content = [];
            }

            return $content;
        } catch (ParseException $exception) {
            $errorFormatter = new OutputFormatter(true);

            echo $errorFormatter->format(
                    sprintf(
                        '<error>[WARNING] YAML File "%s" is invalid, falling back to "[]" as parsed-value.</error>'.
                        PHP_EOL.
                        '<error>Error: %s</error>'.
                        PHP_EOL,
                        $errorFormatter->escape($filename),
                        $errorFormatter->escape($exception->getMessage())
                    )
                ).PHP_EOL
            ;

            return [];
        }
    }
1367
public static function ExtractList($sListName){
            $oThis = self::CreateInstanceIfNotExists();
            $iStart = strpos($oThis->sBuffer, "{list:{$sListName}}");

            if($iStart > 0)
                $iEnd = strpos($oThis->sBuffer, "{end}", $iStart);

            if($iStart > 0 && $iEnd > 0){
                $sNewBuffer = substr($oThis->sBuffer, $iStart, $iEnd-$iStart);
                $oThis->sBuffer = $sNewBuffer."{end}";
            }
        }
887205
public function read($fileName=null)
    {
        $this->_resetFileName($fileName);

        $manifest = array();
        $hashLen = ($this->hashEncoding == 'sha1') ? 40 : 32;
        $lines = readLines($this->fileName, $this->fileEncoding);

        foreach ($lines as $line) {
            $hash = trim(substr($line, 0, $hashLen));
            $payload = trim(substr($line, $hashLen));

            if (strlen($payload) > 0) {
                $manifest[$payload] = $hash;
            }
        }

        $this->data = $manifest;
        return $manifest;
    }
393885
public function getContents(string $fileName)
    {
        if (!file_exists($this->__path . $fileName)) {
            return null;
        }
        $r = include $this->__path . $fileName;
        return $r === false ? null : $r;
    }
486515
public function load($fname)
    {
        $this->fname = $fname;
        if (file_exists($this->fname)) {
            $contents = file_get_contents($this->fname);
            $this->data = json_decode($contents);
        } else {
            $this->data = json_decode("[]");
        }

        $data =& $this->data;
        return $data;
    }
492186
private function fileNameToNamespaceParts(string $name)
    {
        $name = preg_replace('/(.*)(\.[\w\d]+)$/', '$1', $name);
        return array_map(function ($e) {
            $e = ucfirst($e);
            $e = implode("", array_map('ucfirst', explode(".", $e)));
            $e = implode("", array_map('ucfirst', explode("-", $e)));
            return $e;
        }, explode('/', $name));
    }