private function createResource($filesystemPath, $path)
{
$resource = null;
if (is_link($filesystemPath)) {
$baseDir = rtrim($this->baseDir, '/');
$targetFilesystemPath = $this->readLink($filesystemPath);
if (Path::isBasePath($baseDir, $targetFilesystemPath)) {
$targetPath = '/' . Path::makeRelative($targetFilesystemPath, $baseDir);
$resource = new LinkResource($targetPath);
}
}
if (!$resource && is_dir($filesystemPath)) {
$resource = new DirectoryResource($filesystemPath);
}
if (!$resource) {
$resource = new FileResource($filesystemPath);
}
$resource->attachTo($this, $path);
return $resource;
}