OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::anonymous_namespace{miniz_extension.cpp} Namespace Reference

Functions

std::string decode_zip_unicode_path_extra_field (const std::string &extra, const std::string &path)
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 )
99{
100 bool ret = false;
101 if (zip) {
102 FILE *f = mz_zip_get_cfile(zip);
103 ret = bool(isread ? mz_zip_reader_end(zip)
104 : mz_zip_writer_end(zip));
105 if (f) fclose(f);
106 }
107 return ret;
108}
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124

References close_zip(), and Slic3r::f().

Referenced by close_zip().

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

◆ decode_zip_unicode_path_extra_field()

std::string Slic3r::anonymous_namespace{miniz_extension.cpp}::decode_zip_unicode_path_extra_field ( const std::string & extra,
const std::string & path )
33{
34 size_t offset = 0;
35 const mz_uint32 path_crc = mz_crc32(0, reinterpret_cast<const unsigned char*>(path.data()), path.size());
36
37 while (offset + 4 <= extra.size()) {
38 const unsigned char* field = reinterpret_cast<const unsigned char*>(extra.data() + offset);
39 const std::uint16_t len = field[2] | (static_cast<std::uint16_t>(field[3]) << 8);
40 if (offset + 4 + len > extra.size())
41 break;
42
43 if (field[0] == 0x75 && field[1] == 0x70 && len >= 5 && field[4] == 0x01) {
44 const mz_uint32 stored_crc =
45 static_cast<mz_uint32>(field[5]) |
46 (static_cast<mz_uint32>(field[6]) << 8) |
47 (static_cast<mz_uint32>(field[7]) << 16) |
48 (static_cast<mz_uint32>(field[8]) << 24);
49 if (stored_crc == path_crc)
50 return std::string(extra.data() + offset + 9, extra.data() + offset + 4 + len);
51 }
52
53 offset += 4 + len;
54 }
55
56 return Slic3r::decode_path(path.c_str());
57}
std::string decode_path(const char *src)
Definition utils.cpp:1401
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582

References Slic3r::decode_path(), decode_zip_unicode_path_extra_field(), and Slic3r::offset().

Referenced by decode_zip_unicode_path_extra_field().

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 )
60{
61 if (!zip) return false;
62 const char *mode = isread ? "rb" : "wb";
63
64 FILE *f = nullptr;
65#if defined(_MSC_VER) || defined(__MINGW64__)
66 // fname is UTF-8 (the nowide contract). Route it through the shared extended-path helper so an
67 // archive stored past MAX_PATH opens even with LongPathsEnabled off.
68 const std::wstring wide_path = boost::nowide::widen(fname);
69 const std::string extended = boost::nowide::narrow(Slic3r::extended_path(boost::filesystem::path(wide_path)).wstring());
70 f = boost::nowide::fopen(extended.c_str(), mode);
71#elif defined(__GNUC__) && defined(_LARGEFILE64_SOURCE)
72 f = fopen64(fname, mode);
73#else
74 f = fopen(fname, mode);
75#endif
76
77 if (!f) {
78 zip->m_last_error = MZ_ZIP_FILE_OPEN_FAILED;
79 return false;
80 }
81
82 bool res = false;
83 if (isread)
84 {
85 res = mz_zip_reader_init_cfile(zip, f, 0, 0);
86 if (!res)
87 // if we get here it means we tried to open a non-zip file
88 // we need to close the file here because the call to mz_zip_get_cfile() made into close_zip() returns a null pointer
89 // see: https://github.com/prusa3d/PrusaSlicer/issues/3536
90 fclose(f);
91 }
92 else
93 res = mz_zip_writer_init_cfile(zip, f, 0);
94
95 return res;
96}
boost::filesystem::path extended_path(const boost::filesystem::path &path)
Definition utils.cpp:2260

References Slic3r::extended_path(), Slic3r::f(), and open_zip().

Referenced by open_zip().

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