public function locate($path, $currentPath = null, $first = true)
    {
        // Accept actual file paths
        if (file_exists($path)) {
            return $path;
        }

        if (null !== $currentPath && file_exists($currentPath.'/'.$path)) {
            throw new RuntimeException(sprintf(
                'You tried to load the file "%s" using a relative path. '.
                'This functionality is not supported due to a limitation in '.
                'Symfony, because then this file cannot be overridden anymore. '.
                'Please pass the absolute Puli path instead.',
                $path
            ));
        }

        try {
            $resource = $this->repo->get($path);

            while ($resource instanceof LinkResource) {
                $resource = $this->repo->get($resource->getTargetPath());
            }

            if (!$resource instanceof FilesystemResource) {
                throw new InvalidArgumentException(sprintf(
                    'The file "%s" is not a local file.',
                    $path
                ));
            }

            return $first
                ? $resource->getFilesystemPath()
                : array($resource->getFilesystemPath());
        } catch (ResourceNotFoundException $e) {
            throw new InvalidArgumentException(sprintf(
                'The file "%s" could not be found.',
                $path
            ), 0, $e);
        }
    }