public function open(string $mode)
    {
        $read = strpbrk($mode, "r+") !== false;
        $write = strpbrk($mode, "waxc+") !== false;
        $x = strpbrk($mode, "x") !== false;

        $path = $this->getFullPath();
        $fh = @fopen($path, $mode);
        if (is_resource($fh))
            return $fh;

        if ($x && file_exists($path))
            throw new IOException("File already exists: " . $path);
        if ($write && !is_writable($path))
            throw new IOException("File is not writable: " . $path);
        if ($read && !is_readable($path))
            throw new IOException("File is not readable: " . $path);

        throw new IOException("Invalid mode for opening file: " . $mode);
    }