Check if you can do something with the given file or directory.

@param string $prefix
@param string $path

@return bool
518299
public function authorized($prefix, $path)
    {
        // Check blocked resources
        foreach ($this->blocked as $rule) {
            if (preg_match($rule, $path)) {
                return false;
            }
        }

        // Check allowed filesystems
        foreach ($this->allowedPrefixes as $allowedPrefix) {
            if ($allowedPrefix === $prefix) {
                return true;
            }
        }

        // Check allowed resources
        foreach ($this->allowed as $rule) {
            if (preg_match($rule, $path)) {
                return true;
            }
        }

        return false;
    }
793308
public function dir_opendir($path)
    {
        $this->restore();
        if (isset($this->context)) {
            $this->resource = opendir($path, $this->context);
        } else {
            $this->resource = opendir($path);
        }
        $this->intercept();

        return $this->resource !== false;
    }
1192199
protected function isWritable($path) {
        if (!is_dir($path)) {
            // Path does not exist, check parent
            return $this->isWritable(dirname($path));
        }

        // Dir exists, check if it's writable
        return is_writable($path);
    }
1118481
def _prefix_is_authorized(self, path):
        
        path = os.path.abspath(path)
        while True:
            if path in self._prefixes:
                return True
            if path == '/':
                break
            path = os.path.dirname(path)
        return False
1044793
public static function canChmod($path)
	{
		if (!file_exists($path))
		{
			return false;
		}

		$perms = @fileperms($path);

		if ($perms !== false)
		{
			if (@chmod($path, $perms ^ 0001))
			{
				@chmod($path, $perms);

				return true;
			}
		}

		return false;
	}
375186
protected function removePathPrefix($path, $prefix)
    {
        if ($prefix !== '/' && mb_stripos($path, $prefix) === 0) {
            $path = mb_substr($path, mb_strlen($prefix));
        }

        return $path;
    }
886433
public function has(string ...$path): bool
    {
        try {
            $this->get(...$path);
        } catch (ConfigKeyNotFoundException $e) {
            return false;
        }

        return true;
    }
217404
public function isDirExcluded ($path)
	{
		foreach ($this->excludedDirs as $needle)
		{
			if (empty($needle)) {
				continue;
			}

			$needleLen = strlen($needle);
			$pathChunk = substr($path, -$needleLen, $needleLen);

			// check if matches end of $path
			if ($pathChunk == $needle) {
				return true;
			}
		}
		return false;
	}
882297
public static function isWritable($path)
    {
        // recursively return a temporary file path
        if ($path{strlen($path) - 1} == '/') {
            return self::isWritable($path . uniqid(mt_rand()) . '.tmp');
        } elseif (is_dir($path)) {
            return self::isWritable($path . '/' . uniqid(mt_rand()) . '.tmp');
        }

        // check file for read/write capabilities
        $rm = file_exists($path);
        $handle = @fopen($path, 'a');

        if ($handle === false) {
            return false;
        }

        fclose($handle);

        if (!$rm) {
            unlink($path);
        }

        return true;
    }
1103813
public static function isWritable(string $path): bool
    {
        // If it's a directory, test on a temp sub file
        if (is_dir($path)) {
            return static::isWritable($path . DIRECTORY_SEPARATOR . uniqid('test_writable', true) . '.tmp');
        }

        // Remember whether the file already existed
        $exists = file_exists($path);

        if (($f = @fopen($path, 'ab')) === false) {
            return false;
        }

        @fclose($f);

        // Delete the file if it didn't exist already
        if (!$exists) {
            static::removeFile($path);
        }

        return true;
    }
466022
public static function isFile($path): bool
    {
        $path = self::clean($path);
        return file_exists($path) && is_file($path);
    }
868676
def is_prefix(cls, path):
        
        lagofile = paths.Paths(path).prefix_lagofile()
        return os.path.isfile(lagofile)
808398
public static function isWritable($path = false) {

        if($path && self::isFolder($path) && is_writable($path)) {

            return true;
        }

        return false;
    }
369184
protected function checkPath($path)
    {
        foreach ($this->chroots as $chroot) {
            if (StringHelper::contains($path, $chroot)) {
                return true;
            }
        }
        return false;
    }
1355232
private function isPathAccessible($path)
    {
        $uri = $this->httpUtils->generateUri($this->requestStack->getMasterRequest(), $path);

        /** @var \Buzz\Message\Response $res */
        $res = $this->browser->get($uri);
        if ($res->isSuccessful()) {
            return true;
        }

        return false;
    }
395084
public function delete($path)
    {
        [$prefix, $path] = $this->getPrefixAndPath($path);

        return $this->getFilesystem($prefix)->delete($path);
    }
168614
public static function isDirectory(string $path) : bool
    {
        try {
            return ErrorCatcher::run(static function() use ($path) {
                return is_dir($path);
            });
        } catch (\ErrorException $e) {
            throw new IoException('Error checking if ' . $path . ' is a directory', 0, $e);
        }
    }