EllanJiang/GameFramework · error · GameFrameworkException

Access read is invalid.

Error message

Access read is invalid.

What it means

Validation in FileSystemManager.CreateFileSystem: thrown when access is FileSystemAccess.Read, because a newly created file system is being written to and read-only access is contradictory at creation time. Use Read only when opening an existing file system; create with Write (or ReadWrite as supported).

Solutions

  1. Use FileSystemAccess.ReadWrite (or Write) with CreateFileSystem; reserve Read for opening existing file systems.
  2. Restructure open-or-create logic: try Open with Read first, then Create with ReadWrite only if it does not exist.
  3. Map the access argument in wrapper code: force Read to ReadWrite (or reject) on the create path.

Example fix

// before
var fs = fileSystemManager.CreateFileSystem(fullPath, FileSystemAccess.Read, 16, 1024); // throws
// after
var fs = fileSystemManager.CreateFileSystem(fullPath, FileSystemAccess.ReadWrite, 16, 1024);
Defensive patterns

Strategy: validation

Validate before calling

if (access == FileSystemAccess.Read)
    access = FileSystemAccess.ReadWrite; // creation requires write capability
if (access == FileSystemAccess.Unspecified)
    access = FileSystemAccess.ReadWrite;

Type guard

static bool IsCreatableAccess(FileSystemAccess access) => access == FileSystemAccess.Write || access == FileSystemAccess.ReadWrite;

Try / catch

try { fileSystemManager.CreateFileSystem(fullPath, access, maxFileCount, maxBlockCount); }
catch (GameFrameworkException ex) when (ex.Message == "Access read is invalid.") { /* retry with ReadWrite or route to Open instead */ }

Prevention

When it happens

Trigger: Calling FileSystemManager.CreateFileSystem(fullPath, FileSystemAccess.Read, maxFileCount, maxBlockCount).

Common situations: Confusing Open (which accepts Read) with Create (which does not); reusing a Read access variable intended for opening existing file systems; generic open-or-create wrapper passing the caller's access straight through.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/735c673198b4bd01. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/FileSystem/FileSystemManager.cs:156

        {
            if (m_FileSystemHelper == null)
            {
                throw new GameFrameworkException("File system helper is invalid.");
            }

            if (string.IsNullOrEmpty(fullPath))
            {
                throw new GameFrameworkException("Full path is invalid.");
            }

            if (access == FileSystemAccess.Unspecified)
            {
                throw new GameFrameworkException("Access is invalid.");
            }

            if (access == FileSystemAccess.Read)
            {
                throw new GameFrameworkException("Access read is invalid.");
            }

            fullPath = Utility.Path.GetRegularPath(fullPath);
            if (m_FileSystems.ContainsKey(fullPath))
            {
                throw new GameFrameworkException(Utility.Text.Format("File system '{0}' is already exist.", fullPath));
            }

            FileSystemStream fileSystemStream = m_FileSystemHelper.CreateFileSystemStream(fullPath, access, true);
            if (fileSystemStream == null)
            {
                throw new GameFrameworkException(Utility.Text.Format("Create file system stream for '{0}' failure.", fullPath));
            }

            FileSystem fileSystem = FileSystem.Create(fullPath, access, fileSystemStream, maxFileCount, maxBlockCount);
            if (fileSystem == null)
            {
                throw new GameFrameworkException(Utility.Text.Format("Create file system '{0}' failure.", fullPath));

View on GitHub (pinned to d0c010b051)