EllanJiang/GameFramework · error · GameFrameworkException
File system is invalid.
Error message
File system is invalid.
What it means
FileSystemManager.DestroyFileSystem throws this when the fileSystem argument is null. Destroying requires an IFileSystem instance to look up its full path and shut it down; a null reference is rejected immediately.
Solutions
- Null-check the IFileSystem before calling DestroyFileSystem and skip destruction when null.
- Fix the earlier Create/Load failure that left the reference null.
- Ensure Shutdown() (which destroys all file systems) is not mixed with manual DestroyFileSystem calls on already-destroyed instances.
Example fix
// before
fileSystemManager.DestroyFileSystem(fileSystem, false); // NRE if null
// after
if (fileSystem != null)
fileSystemManager.DestroyFileSystem(fileSystem, false); Defensive patterns
Strategy: type-guard
Validate before calling
if (fileSystem == null) return; // nothing to destroy
Type guard
bool CanDestroy(IFileSystem fs) => fs != null;
Try / catch
try { manager.DestroyFileSystem(fs, deletePhysicalFile); }
catch (GameFrameworkException ex) when (ex.Message == "File system is invalid.") { Log.Warning("DestroyFileSystem called with null."); } Prevention
- Null-check file system references before cleanup calls.
- Track created file systems in a collection so references are never null at teardown.
- Prefer manager.Shutdown() for whole-manager teardown instead of per-instance destroys on possibly-null handles.
When it happens
Trigger: Calling DestroyFileSystem(null, deletePhysicalFile) - often the result of a Create/Load call that failed earlier and returned null (or threw) while the variable was still passed onward.
Common situations: Caching the result of CreateFileSystem/LoadFileSystem without checking for the earlier exception; tracking file systems in fields that were never assigned; cleanup code running after a failed initialization.
Related errors
- Stream is invalid.
- Resource manager is invalid.
- Data provider helper is invalid.
- Owner is invalid.
- Resource manager is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/bc802b11c559b039.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/FileSystem/FileSystemManager.cs:236
{
fileSystemStream.Close();
throw new GameFrameworkException(Utility.Text.Format("Load file system '{0}' failure.", fullPath));
}
m_FileSystems.Add(fullPath, fileSystem);
return fileSystem;
}
/// <summary>
/// 销毁文件系统。
/// </summary>
/// <param name="fileSystem">要销毁的文件系统。</param>
/// <param name="deletePhysicalFile">是否删除文件系统对应的物理文件。</param>
public void DestroyFileSystem(IFileSystem fileSystem, bool deletePhysicalFile)
{
if (fileSystem == null)
{
throw new GameFrameworkException("File system is invalid.");
}
string fullPath = fileSystem.FullPath;
((FileSystem)fileSystem).Shutdown();
m_FileSystems.Remove(fullPath);
if (deletePhysicalFile && File.Exists(fullPath))
{
File.Delete(fullPath);
}
}
/// <summary>
/// 获取所有文件系统集合。
/// </summary>
/// <returns>获取的所有文件系统集合。</returns>
public IFileSystem[] GetAllFileSystems()
{View on GitHub (pinned to d0c010b051)