EllanJiang/GameFramework · error · GameFrameworkException
File system is not readable.
Error message
File system is not readable.
What it means
ReadFile(string) returns the bytes of a stored file, but only if the FileSystem was opened with read access. The library throws GameFrameworkException("File system is not readable.") when m_Access is Write-only, because the underlying stream was not opened for reading. Open the file system with FileSystemAccess.Read or ReadWrite to read files.
Solutions
- Open/create the file system with FileSystemAccess.Read or FileSystemAccess.ReadWrite instead of Write.
- Check fileSystem.Access before reading, or use a separate instance opened for reading.
- Restructure code so write-phase and read-phase use distinct file system instances.
Example fix
// before FileSystem fs = fileSystemManager.CreateFileSystem(path, FileSystemAccess.Write, ...); byte[] data = fs.ReadFile(name); // throws // after FileSystem fs = fileSystemManager.CreateFileSystem(path, FileSystemAccess.ReadWrite, ...); byte[] data = fs.ReadFile(name);
Defensive patterns
Strategy: validation
Validate before calling
if (fileSystem.Access == FileSystemAccess.Read || fileSystem.Access == FileSystemAccess.ReadWrite) { var data = fileSystem.ReadFile(name); } Type guard
bool IsReadable(FileSystem fs) => fs.Access == FileSystemAccess.Read || fs.Access == FileSystemAccess.ReadWrite;
Try / catch
try { data = fileSystem.ReadFile(name); } catch (GameFrameworkException ex) { Log.Error("File system not readable: {0}", ex.Message); } Prevention
- Choose the FileSystemAccess flag matching all operations you plan to perform.
- Prefer ReadWrite when unsure.
- Open separate instances for write-only build steps.
When it happens
Trigger: Calling ReadFile on a FileSystem created/opened with FileSystemAccess.Write (write-only).
Common situations: Opening a file system for writing packed files in a build pipeline and later reusing the same instance to read them; copy-pasting open code with the wrong access flag; a resource component configured with Write access while game code calls read APIs.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Results is invalid.
- Results is invalid.
- Owner is invalid.
- Resource manager is invalid.
- Data provider helper is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/0c5187bf648835f5.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/FileSystem/FileSystem.cs:336
{
if (string.IsNullOrEmpty(name))
{
throw new GameFrameworkException("Name is invalid.");
}
return m_FileDatas.ContainsKey(name);
}
/// <summary>
/// 读取指定文件。
/// </summary>
/// <param name="name">要读取的文件名称。</param>
/// <returns>存储读取文件内容的二进制流。</returns>
public byte[] ReadFile(string name)
{
if (m_Access != FileSystemAccess.Read && m_Access != FileSystemAccess.ReadWrite)
{
throw new GameFrameworkException("File system is not readable.");
}
if (string.IsNullOrEmpty(name))
{
throw new GameFrameworkException("Name is invalid.");
}
FileInfo fileInfo = GetFileInfo(name);
if (!fileInfo.IsValid)
{
return null;
}
int length = fileInfo.Length;
byte[] buffer = new byte[length];
if (length > 0)
{
m_Stream.Position = fileInfo.Offset;View on GitHub (pinned to d0c010b051)