diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index 411f1161a8..9435a0e970 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -1093,7 +1093,8 @@ void DirectoryFileSystem::DoState(PointerWrap &p) { Do(p, entry.guestFilename); Do(p, entry.access); u32 err; - bool opened = entry.hFile.Open(basePath, entry.guestFilename, entry.access, err); + // The original open created the file, so an exclusive create would fail now. + bool opened = entry.hFile.Open(basePath, entry.guestFilename, (FileAccess)(entry.access & ~FILEACCESS_EXCL), err); bool brokenFile = !opened; if (!opened) { ERROR_LOG(Log::FileSystem, "Failed to reopen file while loading state: %s", entry.guestFilename.c_str()); diff --git a/Core/FileSystems/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index b0ccb9ec22..aae8acc549 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -857,6 +857,12 @@ void ISOFileSystem::DoState(PointerWrap &p) { std::string path; Do(p, path); of.file = GetFromPath(path); + if (!of.file) { + // Loaded against a different image. Like a file that's gone from a directory, + // drop the handle rather than keep one that points at nothing. + ERROR_LOG(Log::FileSystem, "Failed to reopen file while loading state: %s", path.c_str()); + continue; + } } else { of.file = NULL; }