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

Function zip_open_buffer_managed

common/ZipHelpers.h:36–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36static inline std::unique_ptr<zip_t, void (*)(zip_t*)> zip_open_buffer_managed(const void* buffer, size_t size, int flags, int freep, zip_error_t* ze)
37{
38 zip_source_t* zs = zip_source_buffer_create(buffer, size, freep, ze);
39 zip_t* zip = nullptr;
40 if (zs && !(zip = zip_open_from_source(zs, flags, ze)))
41 {
42 // have to clean up source
43 zip_source_free(zs);
44 }
45
46 return std::unique_ptr<zip_t, void (*)(zip_t*)>(zip, [](zip_t* zf) {
47 if (!zf)
48 return;
49
50 int err = zip_close(zf);
51 if (err != 0)
52 {
53 Console.Error("Failed to close zip file: %d", err);
54 zip_discard(zf);
55 }
56 });
57}
58
59static inline std::unique_ptr<zip_file_t, int (*)(zip_file_t*)> zip_fopen_managed(zip_t* zip, const char* filename, zip_flags_t flags)
60{

Callers

nothing calls this directly

Calls 6

zip_source_buffer_createFunction · 0.85
zip_open_from_sourceFunction · 0.85
zip_source_freeFunction · 0.85
zip_closeFunction · 0.85
zip_discardFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected