Beispiel #1
0
 public function filterFile(string $file = null)
 {
     $file = DocMen::convertUnixPath($file);
     if (!isset($this->_files[$file])) {
         $isFile = is_file($file) && is_readable($file);
         $dir = $this->source;
         $base = $dir . '/';
         if (!$isFile) {
             // 空文件,将视作为php internal
             if (empty($file)) {
                 $dir = $this->addDir('');
                 $path = '';
                 $priority = 0;
             } else {
                 return false;
             }
         } else {
             if (strpos($file, $base) === 0) {
                 $path = substr($file, strlen($base));
             } else {
                 $dir = compare_path($this->source, $file);
                 if (empty($dir)) {
                     $dir = $this->addDir(dirname($file));
                     $path = basename($file);
                 } else {
                     $dir = $this->addDir($dir);
                     $path = substr($file, strlen($dir . '/'));
                 }
             }
         }
         $key = $path;
         $id = $this->getDirIndex($dir);
         $data = ['isFile' => is_file($file), 'dir' => $id, 'path' => $path];
         // 写入基础数据
         $this->_files[$file] = $this->_files[$path] = $key;
         $this->files[$key] = $data;
         // 写入排序数据
         $this->_filesSort['priority'][$path] = $this->getFilePriority($path);
         $this->_filesSort['external'][$path] = $id;
         $this->_filesSort['depth'][$path] = count(explode('/', $path));
         $this->_filesSort['name'][$path] = $path;
         return $data;
     }
     $index = $this->_files[$file];
     return $this->files[$index];
 }