public function deleteThumb() { $dirThumb = Lib::gpath() . "{$this->dir}/.thumbs"; if (is_dir($dirThumb)) { $d = opendir($dirThumb); if ($d) { while (($e = readdir($d)) !== false) { if ($e == '.' || $e == '..') { continue; } if (is_dir($dirThumb . '/' . $e)) { $path = $dirThumb . '/' . $e . '/' . $this->name . '.jpg'; if (is_file($path)) { @unlink($path); } } } } } }
static function findByDir($dir = '', $isHidden = true) { $hidden = false; if ($isHidden) { $hidden = Cfg::get('hidden', false); } $dir = ltrim($dir, '/'); $path = Lib::gpath($dir); $res = array(); $d = opendir($path); if ($d) { while (($e = readdir($d)) !== false) { if ($e == '.' || $e == '..') { continue; } if (is_dir($path . '/' . $e) && !($hidden && preg_match($hidden, $e))) { $res[] = new self($dir, $e, array()); } } } return $res; }
static function findByDir($dir, $isInfo = true, $isHidden = true) { $hidden = false; if ($isHidden) { $hidden = Cfg::get('hidden', false); } $dir = ltrim($dir, '/'); $path = Lib::gpath($dir); $res = array(); $d = opendir($path); if ($d) { $files = array(); while (($e = readdir($d)) !== false) { if ($e == '.' || $e == '..') { continue; } if ($hidden == false || !preg_match($hidden, $e)) { $file = BasefileModel::createFromPath($dir . '/' . $e, $isInfo); if ($file) { if ($file->type == 'folder') { $res[] = $file; } else { $files[] = $file; } } } } $res = array_merge($res, $files); } return $res; }
/** * Переносит файл в директорию target */ public function moveTo($target) { $target = Lib::gpath($target); return rename($this->getPath(), $target . '/' . $this->name); }