Finds single file at given path.

@param string $path

@throws \ArgentCrusade\Selectel\CloudStorage\Exceptions\FileNotFoundException

@return \ArgentCrusade\Selectel\CloudStorage\Contracts\FileContract
773950
public function find($path)
    {
        $file = $this->findFileAt($path);

        if (is_null($file)) {
            throw new FileNotFoundException('File "'.$path.'" was not found.');
        }

        return new File($this->api, $this->containerName(), $file);
    }
206615
public static function get($path)
    {
        $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
        if (!isset(self::$fileTypes[$ext])) {
            return false;
        }
        return self::$fileTypes[$ext];
    }
140422
public static function create($path)
    {
        $file = new static($path);

        if (! is_dir(dirname($path))) {
            mkdir(dirname($path), 0755, true);
        }

        if (! $file->exists()) {
            touch($path);
        }

        return $file;
    }
933798
private function getFilePathCollection($path)
    {
        $key = \array_flip($this->filePathMapping)[$path];

        return $this->filePathCollection[$key];
    }
740677
public function find(string $path): AssetFileInterface
    {
        if ($this->isExternal($path)) {
            return (new File($this->files))
                ->setPath('')
                ->setUrl($path)
                ->setExternal(true)
                ->setType($path);
        }

        $path = trim($path, '\/');

        foreach ($this->locations as $dir => $url) {
            if ($this->files->exists($fullPath = $dir.'/'.$path)) {
                return (new File($this->files))
                    ->setPath($fullPath)
                    ->setUrl($url.'/'.$path)
                    ->setExternal(false)
                    ->setType($fullPath);
            }
        }

        throw new AssetException('Unable to find the asset with the following path: '.$path);
    }
925251
public function setPath($path)
    {
        $this->path = $path;
        $fileFullPath = "{$this->rootPath}/{$this->path}";
        // readable ?
        if (file_exists($fileFullPath)) {
            $this->file = $fileFullPath;
            return $this;
        }
        // absolute path ?
        if (file_exists($path) && strpos($path, $this->rootPath) === 0) {
            $this->file = $path;
            $this->rootPath = '/';
        } else {
            error_log("[BEAR.Ace] 404: {$fileFullPath}");
            throw new Exception('Not found ' . $fileFullPath, 404);
        }

        return $this;
    }
803270
protected function getExistsPath($path)
    {
        $fullPath = $this->concatPaths($path);

        if (!file_exists($fullPath)) {
            $fullPath = $this->getExistsPath(pathinfo($fullPath, PATHINFO_DIRNAME));
        }

        return $fullPath;
    }
956996
public function find($path)
    {
        foreach (array_keys($this->pathLookupTable) as $key) {
            if (starts_with($path, $key)) {
                return $key;
            }
        }
    }
468220
public function getRequire( string $path )
	{
		if( $this->isFile( $path ) )
		{
			return $this->callback(static function($file) {
				/** @noinspection PhpIncludeInspection */
				return require $file;
			}, $path);
		}
		throw new NotFoundFileException($path,"File does not exist at path '{$path}'" );
	}
1044459
protected function loadFile($path)
    {
        if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
            throw new \InvalidArgumentException('Can only parse files with ".php" extensions');
        }
        if (!file_exists($path)) {
            throw new \InvalidArgumentException(sprintf('Failed to find \'%s\' file.', $path));
        }

        return file_get_contents($path);
    }
906622
private function getValidPath($path)
    {
        // If `$path` is array
        if (is_array($path)) {
            return $this->getPathFromArray($path);
        }

        // If `$path` is a directory
        if (is_dir($path)) {
            $paths = glob($path . '/*.*');
            if (empty($paths)) {
                throw new EmptyDirectoryException("Configuration directory: [$path] is empty");
            }
            return $paths;
        }

        // If `$path` is not a file, throw an exception
        if (!file_exists($path)) {
            throw new FileNotFoundException("Configuration file: [$path] cannot be found");
        }
        return array($path);
    }
278761
public function fileAt($path)
    {
        $file = $this->nodeAt($path);

        if (!$file instanceof File) {
            throw new NotFileException();
        }

        return $file;
    }
90965
public function getCollectionAsset($path)
    {
        if (!is_string($path)) {
            throw new Exception\RuntimeException(
                'Asset should be of type string. got ' . gettype($path)
            );
        }

        $asset = $this->resolveFile($path);

        if (empty($asset)) {
            throw new Exception\RuntimeException(
                'Unable to locate file: '.$path
            );
        }

        $this->getAssetFilterManager()->setFilters($path, $asset);

        return $asset;
    }
1342527
public function getPath(string $path): Path
    {
        if (!$this->hasPath($path)) {
            throw new \InvalidArgumentException(
                "Path '$path' does not exist (have " . implode(', ', array_keys($this->paths)) . ')'
            );
        }

        return $this->paths[$path];
    }
933703
public function setPath($path)
    {
        if (file_exists($path)) {
            $this->path = $path;
        } else {
            throw new NotFoundException(
                sprintf('The requested page was not found (searching "%s")!', $path)
            );
        }
        return $this;
    }
1001693
public function getSourcePath($path)
    {
        $path = trim($path, '/');
        
        $baseUrl = $this->baseUrl.'/';

        if (substr($path, 0, strlen($baseUrl)) === $baseUrl) {
            $path = trim(substr($path, strlen($baseUrl)), '/');
        }

        if ($path === '') {
            throw new FileNotFoundException('Image path missing.');
        }

        if ($this->sourcePathPrefix) {
            $path = $this->sourcePathPrefix.'/'.$path;
        }

        return rawurldecode($path);
    }
802519
public function initFromPath($path)
    {
        if ( ! file_exists($path)) {
            throw new \Hail\Image\Exception\NotReadableException(
                "Unable to find file ({$path})."
            );
        }

        // get mime type of file
        $mime = MimeType::getMimeTypeByFile($path);

        // define core
        switch (strtolower($mime)) {
            case 'image/png':
            case 'image/x-png':
                $core = @imagecreatefrompng($path);
                break;

            case 'image/jpg':
            case 'image/jpeg':
            case 'image/pjpeg':
                $core = @imagecreatefromjpeg($path);
                if (!$core) {
                    $core= @imagecreatefromstring(file_get_contents($path));
                }
                break;

            case 'image/gif':
                $core = @imagecreatefromgif($path);
                break;

            case 'image/webp':
            case 'image/x-webp':
                if ( ! function_exists('imagecreatefromwebp')) {
                    throw new \Hail\Image\Exception\NotReadableException(
                        "Unsupported image type. GD/PHP installation does not support WebP format."
                    );
                }
                $core = @imagecreatefromwebp($path);
                break;

            default:
                throw new \Hail\Image\Exception\NotReadableException(
                    "Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files."
                );
        }

        if (empty($core)) {
            throw new \Hail\Image\Exception\NotReadableException(
                "Unable to decode image from file ({$path})."
            );
        }

        $this->gdResourceToTruecolor($core);

        // build image
        $image = $this->initFromGdResource($core);
        $image->mime = $mime;
        $image->setFileInfoFromPath($path);

        return $image;
    }