public static function lock($key) { $cacheFile = self::path($key); $cacheDir = dirname($cacheFile); if (!is_dir($cacheDir)) { if (!ZOL_File::mkdir($cacheDir, 0755, true)) { // make sure the failure isn't because of a concurency issue if (!is_dir($cacheDir)) { throw new ZOL_Exception("Could not create cache directory"); } } } @touch($cacheFile . '.lock'); }
/** * 创建缩略图 * * @param string $path 原图 * @param string $toPath 生成后的图 * @param string $size 图片尺寸 */ public function makeThumb($path, $toPath, $size) { $size = strtolower($size); $toDir = dirname($toPath); is_dir($toDir) || ZOL_File::mkdir($toDir); system("convert -geometry {$size} {$path} {$toPath} "); return $this; }