MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / SaveState_ZipToDisk

Function SaveState_ZipToDisk

pcsx2/SaveState.cpp:1032–1069  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1030}
1031
1032bool SaveState_ZipToDisk(
1033 std::unique_ptr<ArchiveEntryList> srclist, std::unique_ptr<SaveStateScreenshotData> screenshot,
1034 const char* filename, Error* error)
1035{
1036 zip_error_t ze = {};
1037 zip_source_t* zs = zip_source_file_create(filename, 0, 0, &ze);
1038 zip_t* zf = nullptr;
1039 if (zs && !(zf = zip_open_from_source(zs, ZIP_CREATE | ZIP_TRUNCATE, &ze)))
1040 {
1041 Error::SetStringFmt(error,
1042 TRANSLATE_FS("SaveState", "Failed to open zip file '{}' for save state: {}."),
1043 filename, zip_error_strerror(&ze));
1044
1045 // have to clean up source
1046 zip_source_free(zs);
1047 return false;
1048 }
1049
1050 // discard zip file if we fail saving something
1051 if (!SaveState_AddToZip(zf, srclist.get(), screenshot.get()))
1052 {
1053 Error::SetStringFmt(error,
1054 TRANSLATE_FS("SaveState", "Failed to save state to zip file '{}'."), filename);
1055 zip_discard(zf);
1056 return false;
1057 }
1058
1059 // force the zip to close, this is the expensive part with libzip.
1060 if (zip_close(zf) != 0)
1061 {
1062 Error::SetStringFmt(error,
1063 TRANSLATE_FS("SaveState", "Failed to save state to zip file '{}': {}."), filename, zip_strerror(zf));
1064 zip_discard(zf);
1065 return false;
1066 }
1067
1068 return true;
1069}
1070
1071bool SaveState_ReadScreenshot(const std::string& filename, u32* out_width, u32* out_height, std::vector<u32>* out_pixels)
1072{

Callers 1

ZipSaveStateMethod · 0.85

Calls 9

zip_open_from_sourceFunction · 0.85
zip_error_strerrorFunction · 0.85
zip_source_freeFunction · 0.85
SaveState_AddToZipFunction · 0.85
zip_discardFunction · 0.85
zip_closeFunction · 0.85
zip_strerrorFunction · 0.85
zip_source_file_createFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected