diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 58e925960c..7b57992379 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -783,6 +783,11 @@ static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version, case CELL_SAVEDATA_FILEOP_WRITE: { fs::file file(dir_path + file_path, fs::write + fs::create); + if (!file) + { + fmt::throw_exception("Failed to open file. The file might be read-only: %s%s" HERE, dir_path, file_path); + } + file.seek(fileSet->fileOffset); const auto start = static_cast(fileSet->fileBuf.get_ptr()); std::vector buf(start, start + std::min(fileSet->fileSize, fileSet->fileBufSize)); @@ -801,6 +806,11 @@ static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version, case CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC: { fs::file file(dir_path + file_path, fs::write + fs::create); + if (!file) + { + fmt::throw_exception("Failed to open file. The file might be read-only: %s%s" HERE, dir_path, file_path); + } + file.seek(fileSet->fileOffset); const auto start = static_cast(fileSet->fileBuf.get_ptr()); std::vector buf(start, start + std::min(fileSet->fileSize, fileSet->fileBufSize));