private function setTimestampHelper(FileSystemInfo $info, $timestamp) { $parentInfo = $info; $rootDirInfo = new DirectoryInfo(Config::getRootDir()); $endDirPath = $rootDirInfo->getParent()->getFullName(); do { $this->cache->save($parentInfo->getFullName(), $timestamp); if ($parentInfo instanceof FileInfo) { $parentInfo = $parentInfo->getDirectory(); } else { $parentInfo = $parentInfo->getParent(); } } while ($parentInfo != null && strcasecmp($parentInfo->getFullName(), $endDirPath) != 0); }
public function deleteFile(Application $app, Request $request, $path) { $realPath = Path::getRealPath($path, Config::getRootDir()); if (!Path::exists($realPath)) { return new Response('', Response::HTTP_NOT_FOUND); } if (strcasecmp($realPath, Config::getRootDir()) == 0) { return $this->createResponse(Response::HTTP_BAD_REQUEST, "Cannot delete root directory"); } if (Path::isDir($realPath)) { $dirInfo = new DirectoryInfo($realPath); if (count($dirInfo->getFileSystemInfos()) > 0) { return $this->createResponse(Response::HTTP_BAD_REQUEST, "Directory '{$path}' is not empty"); } rmdir($realPath); } else { unlink($realPath); } $info = Path::getInfo($realPath); $app['fsrapi.cache']->setTimestampForInfo($info); return new Response(); }