| 113 | |
| 114 | |
| 115 | void SlpkInterface::unarchive() |
| 116 | { |
| 117 | #pragma pack(1) |
| 118 | struct zheader |
| 119 | { |
| 120 | uint16_t m_version; |
| 121 | uint16_t m_purpose; |
| 122 | uint16_t m_compression; |
| 123 | uint32_t m_time; |
| 124 | uint32_t m_crc; |
| 125 | uint32_t m_compressedSize; |
| 126 | uint32_t m_uncompressedSize; |
| 127 | uint16_t m_nameLen; |
| 128 | uint16_t m_extraLen; |
| 129 | }; |
| 130 | #pragma pack() |
| 131 | |
| 132 | ILeStream in(m_filename); |
| 133 | if (!in) |
| 134 | throw pdal_error("Couldn't open file '" + m_filename + "'."); |
| 135 | |
| 136 | zheader h; |
| 137 | std::string name; |
| 138 | std::vector<char> extra; |
| 139 | int32_t magic; |
| 140 | |
| 141 | in.get(reinterpret_cast<char *>(&magic), sizeof(magic)); |
| 142 | while (magic == 0x04034b50) |
| 143 | { |
| 144 | in >> h.m_version; |
| 145 | in >> h.m_purpose; |
| 146 | in >> h.m_compression; |
| 147 | in >> h.m_time; |
| 148 | in >> h.m_crc; |
| 149 | in >> h.m_compressedSize; |
| 150 | in >> h.m_uncompressedSize; |
| 151 | in >> h.m_nameLen; |
| 152 | in >> h.m_extraLen; |
| 153 | |
| 154 | in.get(name, h.m_nameLen); |
| 155 | if (h.m_extraLen) |
| 156 | { |
| 157 | extra.resize(h.m_extraLen); |
| 158 | in.get(extra); |
| 159 | } |
| 160 | |
| 161 | if (h.m_compression != 0) |
| 162 | throw i3s::EsriError("Found compressed file in slpk archive."); |
| 163 | if (h.m_compressedSize != h.m_uncompressedSize) |
| 164 | throw i3s::EsriError("Compressed and uncompressed sizes don't " |
| 165 | "match in slpk archive."); |
| 166 | m_locMap[name] = { (size_t)in.position(), h.m_compressedSize }; |
| 167 | in.skip(h.m_compressedSize); |
| 168 | in.get(reinterpret_cast<char *>(&magic), sizeof(magic)); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | |