改进文件缓存和日志的存储文件名命名规范

This commit is contained in:
thinkphp
2016-07-29 17:10:04 +08:00
parent de1553a61d
commit 14112f2420
2 changed files with 13 additions and 14 deletions

View File

@@ -69,19 +69,17 @@ class File
$name = md5($name);
if ($this->options['cache_subdir']) {
// 使用子目录
$dir = '';
$len = $this->options['path_level'];
for ($i = 0; $i < $len; $i++) {
$dir .= $name{$i} . DS;
}
if (!is_dir($this->options['path'] . $dir)) {
mkdir($this->options['path'] . $dir, 0755, true);
}
$filename = $dir . $this->options['prefix'] . $name . '.php';
} else {
$filename = $this->options['prefix'] . $name . '.php';
$name = substr($md5, 0, 2) . DS . substr($md5, 2);
}
return $this->options['path'] . $filename;
if ($this->options['prefix']) {
$name = $this->options['prefix'] . DS . $name;
}
$filename = $this->options['path'] . $name . '.php';
$dir = dirname($filename);
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
return $filename;
}
/**