protected static function getPathFields(Path $path) { $ret = array(); $ret['path'] = $path->getRelative(); $ret['path_hash'] = $path->getHash(); $ret['directory'] = $path->isDir(); $ret['size'] = $path->getSize(); $ret['created'] = date('Y-m-d H:i:s', $path->getCTime()); $ret['modified'] = date('Y-m-d H:i:s', $path->getMTime()); return $ret; }
protected function addWatches($in, Path $path, &$watches) { if (!$path->isDir()) { // not in a directory, bail return; } $wd = inotify_add_watch($in, $path->getPathname(), $this->computedMask); $watches[$wd] = $path; printf("\rAdding watches... %d", count($watches)); // recurse into this directory's children $children = $path->getChildren(); foreach ($children as $child) { if ($child->isDir()) { $this->addWatches($in, $child, $watches); } } }
private function getInfosHelper($currentPath, $infoKind, $searchOptions, &$infos) { $paths = array_diff(scandir($currentPath), array('..', '.')); foreach ($paths as $path) { $path = Path::combine($currentPath, $path); if (Path::isDir($path)) { if (($infoKind & self::DIRECTORY) != 0) { $directoryInfo = new DirectoryInfo($path); array_push($infos, $directoryInfo); } if ($searchOptions === self::ALL_DIRECTORIES) { $this->getInfosHelper($path, $infoKind, $searchOptions, $infos); } } else { if (($infoKind & self::FILE) != 0) { $fileInfo = new FileInfo($path); array_push($infos, $fileInfo); } } } }