48 using namespace cacao;
53 #define HASHTABLE_CLASSES_SIZE (1 << 10)
62 #define SIGNATURE_LENGTH 4
105 #define CDSFH_HEADER_SIZE 46
107 #define CDSFH_SIGNATURE 0x02014b50
108 #define CDSFH_COMPRESSION_METHOD 10
109 #define CDSFH_COMPRESSED_SIZE 20
110 #define CDSFH_UNCOMPRESSED_SIZE 24
111 #define CDSFH_FILE_NAME_LENGTH 28
112 #define CDSFH_EXTRA_FIELD_LENGTH 30
113 #define CDSFH_FILE_COMMENT_LENGTH 32
114 #define CDSFH_RELATIVE_OFFSET 42
115 #define CDSFH_FILENAME 46
147 #define EOCDR_SIGNATURE 0x06054b50
148 #define EOCDR_ENTRIES 10
149 #define EOCDR_OFFSET 16
170 if ((fd = ::open(path, O_RDONLY)) == -1)
183 if ((len = lseek(fd, 0, SEEK_END)) == -1)
188 u1 *filep = (
u1*) mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0);
198 for (p = filep + len; p >= filep; p--)
234 const char *classext = filename + cdsfh.
filenamelength - strlen(
".class");
241 if (strncmp(classext,
".class", strlen(
".class")) == 0)
296 switch (compressionmethod) {
301 zs.avail_in = compressedsize;
303 zs.avail_out = uncompressedsize;
311 if (inflateInit2(&zs, -MAX_WBITS) != Z_OK)
312 vm_abort(
"zip_get: inflateInit2 failed: %s", strerror(errno));
316 err = inflate(&zs, Z_SYNC_FLUSH);
318 if ((err != Z_STREAM_END) && (err != Z_OK))
319 vm_abort(
"zip_get: inflate failed: %s", strerror(errno));
323 if (inflateEnd(&zs) != Z_OK)
324 vm_abort(
"zip_get: inflateEnd failed: %s", strerror(errno));
329 MCOPY(dst, indata,
u1, compressedsize);
333 vm_abort(
"zip_get: unknown compression method %d", compressionmethod);
#define CDSFH_RELATIVE_OFFSET
#define CDSFH_EXTRA_FIELD_LENGTH
Entry & insert(const T &t)
#define CDSFH_UNCOMPRESSED_SIZE
#define CDSFH_HEADER_SIZE
void vm_abort(const char *text,...)
#define CDSFH_COMPRESSION_METHOD
#define LFH_FILE_NAME_LENGTH
void get(uint8_t *dst) const
#define HASHTABLE_CLASSES_SIZE
static Utf8String from_utf8(const char *, size_t)
#define CDSFH_FILE_NAME_LENGTH
static uint16_t read_u2_le(const uint8_t *src)
static ZipFile * open(const char *path)
Load zip archive.
#define MCOPY(dest, src, type, num)
#define LFH_EXTRA_FIELD_LENGTH
static uint32_t read_u4_le(const uint8_t *src)
#define CDSFH_FILE_COMMENT_LENGTH
#define CDSFH_COMPRESSED_SIZE