Validate a file path is a valid response body.

@param string $path The path to the file.
@throws \Cake\Http\Exception\NotFoundException
@return \Cake\Filesystem\File
769933
protected function validateFile($path)
    {
        if (strpos($path, '../') !== false || strpos($path, '..\\') !== false) {
            throw new NotFoundException(__d('cake', 'The requested file contains `..` and will not be read.'));
        }
        if (!is_file($path)) {
            deprecationWarning(
                'Automatic prefixing of paths with `APP` by `Response::file()` and `withFile()` is deprecated. ' .
                'Use absolute paths instead.'
            );
            $path = APP . $path;
        }
        if (!Folder::isAbsolute($path)) {
            deprecationWarning(
                'Serving files via `file()` or `withFile()` using relative paths is deprecated.' .
                'Use an absolute path instead.'
            );
        }

        $file = new File($path);
        if (!$file->exists() || !$file->readable()) {
            if (Configure::read('debug')) {
                throw new NotFoundException(sprintf('The requested file %s was not found or not readable', $path));
            }
            throw new NotFoundException(__d('cake', 'The requested file was not found'));
        }

        return $file;
    }
937978
public function delete($path) {
		// Process Request
		$url = $this->absolutePath($path);
		$request  = $this->http->request('DELETE', $url, []);
		return $this->validateResponse($request)->getBody();
	}
754329
public function assertPathIsNot($path)
    {
        $actualPath = parse_url($this->driver->getCurrentURL(), PHP_URL_PATH) ?? '';

        PHPUnit::assertNotEquals(
            $path, $actualPath,
            "Path [{$path}] should not equal the actual value."
        );

        return $this;
    }
1150756
public static function checkPath($path)
    {
        if (!is_string($path)) {
            throw new InvalidArgumentException(sprintf("String expected as path, got '%s' instead", gettype($path)));
        }
        if (!file_exists($path)) {
            throw new InvalidArgumentException(sprintf("'%s' does not exist", $path));
        }

        if (!is_dir($path)) {
            throw new InvalidArgumentException(sprintf("'%s' is not a directory", $path));
        }

        if (!is_readable($path)) {
            throw new InvalidArgumentException(sprintf("'%s' is not readable", $path));
        }

        return true;
    }
1073233
private function resolveRemotePath($path)
    {
        if (!isset($this->resolvedRemotePath[$path])) {
            $resolvedPath = $this->volatileFolder->getNewPath();
            if ($this->remoteFilesystem->copy($path, $path, $resolvedPath) !== true) {
                throw new Exception\PathNotFound($path);
            }
            $this->resolvedRemotePath[$path] = $resolvedPath;
        }

        return $this->resolvedRemotePath[$path];
    }
47061
public function assertPresent($path)
    {
        if ($this->config->get('disable_asserts', false) === false && ! $this->has($path)) {
            throw new FileNotFoundException($path);
        }
    }
767967
public function get($path)
    {
        $path = self::validatePath($path);
        $fullPath = $this->getMediaPath($path);
        return $this->getStorageDisk()->get($fullPath);
    }
884013
public function filePath($path)
    {
        $file = $this->realPath($path);
        if (!is_file($file)) {
            throw new \InvalidArgumentException(sprintf('The path is not a file: %s', $file));
        }

        return $path;
    }
402932
public static function get($path)
    {
        if (is_dir($path)) {
            return new filesystem\Directory($path);
        }
        return new filesystem\File($path);
    }
444423
public function assertPresent($path)
    {
        if ($this->getConfig('disable_asserts', false) === false && !$this->has($path)) {
            throw new FileNotFoundException($path);
        }
    }
518030
public static function check($path)
	{
		if (strpos($path, '..') !== false)
		{
			throw new \Exception('JPath::check Use of relative paths not permitted', 20);
		}

		$path = self::clean($path);

		if ((JPATH_ROOT != '') && strpos($path, self::clean(JPATH_ROOT)) !== 0)
		{
			throw new \Exception('JPath::check Snooping out of bounds @ ' . $path, 20);
		}

		return $path;
	}
218159
public function assertMissing($path)
    {
        $paths = Arr::wrap($path);

        foreach ($paths as $path) {
            PHPUnit::assertFalse(
                $this->exists($path), "Found unexpected file at path [{$path}]."
            );
        }

        return $this;
    }
341237
public function nodeAt($path)
    {
        $pathParts = array_filter(explode('/', str_replace('\\', '/', $path)), 'strlen');

        $node = $this->root();

        foreach ($pathParts as $level) {
            if ($node instanceof File) {
                throw new NotFoundException();
            }
            $node = $node->childAt($level);
        }

        return $node;
    }
613071
public function parse($path)
    {
        $fullPath = strstr($path, '.config.php') ? $path : $path . '.config.php';
        if (!file_exists($fullPath))
        {
            throw new FileNotFoundException($fullPath);
        }

        return include($fullPath);
    }
469750
public function handle($path)
    {
        $file = $this->filesystem->getFile($path);

        return $this->filePermissions->authorized($file->getMountPoint(), $file->getPath());
    }
1191293
public function fromPath($path)
    {
        $mimetype = null;

        if (static::isSupported())
        {
            if (!is_file($path)) {
                throw new \RuntimeException('File not found at '.$path);
            }

            if (!is_readable($path)) {
                throw new \RuntimeException('File not readable at '.$path);
            }

            if ($finfo = new \finfo(FILEINFO_MIME_TYPE, $this->getConfig()->magic_file)) {
                $mimetype = $finfo->file($path);
            }
        }

        return $mimetype;
    }
724699
public static function fromUnReadableFile($path)
    {
        if (! file_exists($path)) {
            return new self(sprintf('Invalid path provided, the path "%s" does not seem to exist', $path));
        }

        if (is_dir($path)) {
            return new self(sprintf('The provided path "%s" is a directory, and it cannot be read as a file', $path));
        }

        return new self(sprintf('The provided path "%s" is invalid', $path));
    }