Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::anonymous_namespace{miniz_extension.cpp} Namespace Reference

Functions

bool open_zip (mz_zip_archive *zip, const char *fname, bool isread)
 
bool close_zip (mz_zip_archive *zip, bool isread)
 

Function Documentation

◆ close_zip()

bool Slic3r::anonymous_namespace{miniz_extension.cpp}::close_zip ( mz_zip_archive zip,
bool  isread 
)
50{
51 bool ret = false;
52 if (zip) {
53 FILE *f = mz_zip_get_cfile(zip);
54 ret = bool(isread ? mz_zip_reader_end(zip)
55 : mz_zip_writer_end(zip));
56 if (f) fclose(f);
57 }
58 return ret;
59}
mz_bool mz_zip_reader_end(mz_zip_archive *pZip)
Definition miniz.c:3845
mz_bool mz_zip_writer_end(mz_zip_archive *pZip)
Definition miniz.c:7575
MZ_FILE * mz_zip_get_cfile(mz_zip_archive *pZip)
Definition miniz.c:7889

References close_zip(), Slic3r::f(), mz_zip_get_cfile(), mz_zip_reader_end(), mz_zip_writer_end(), and Slic3r::zip().

Referenced by close_zip().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ open_zip()

bool Slic3r::anonymous_namespace{miniz_extension.cpp}::open_zip ( mz_zip_archive zip,
const char *  fname,
bool  isread 
)
15{
16 if (!zip) return false;
17 const char *mode = isread ? "rb" : "wb";
18
19 FILE *f = nullptr;
20#if defined(_MSC_VER) || defined(__MINGW64__)
21 f = boost::nowide::fopen(fname, mode);
22#elif defined(__GNUC__) && defined(_LARGEFILE64_SOURCE)
23 f = fopen64(fname, mode);
24#else
25 f = fopen(fname, mode);
26#endif
27
28 if (!f) {
30 return false;
31 }
32
33 bool res = false;
34 if (isread)
35 {
36 res = mz_zip_reader_init_cfile(zip, f, 0, 0);
37 if (!res)
38 // if we get here it means we tried to open a non-zip file
39 // we need to close the file here because the call to mz_zip_get_cfile() made into close_zip() returns a null pointer
40 // see: https://github.com/prusa3d/PrusaSlicer/issues/3536
41 fclose(f);
42 }
43 else
44 res = mz_zip_writer_init_cfile(zip, f, 0);
45
46 return res;
47}
mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags)
Definition miniz.c:5788
mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64 archive_size, mz_uint flags)
Definition miniz.c:3984
mz_zip_error m_last_error
Definition miniz.h:1061
@ MZ_ZIP_FILE_OPEN_FAILED
Definition miniz.h:1034

References Slic3r::f(), MZ_ZIP_FILE_OPEN_FAILED, mz_zip_reader_init_cfile(), mz_zip_writer_init_cfile(), open_zip(), and Slic3r::zip().

Referenced by open_zip().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: