57 /* magic bytes that identifies a compressed resource header*/
58 static const u4 resource_header_magic = 0xCAFEFAFA;
59 u4 _magic; // Resource header
60 u8 _size; // Resource size
61 u8 _uncompressed_size; // Expected uncompressed size
62 u4 _decompressor_name_offset; // Strings table decompressor offset
63 u4 _decompressor_config_offset; // Strings table config offset
64 u1 _is_terminal; // Last decompressor 1, otherwise 0.
65 };
66
67 /*
68 * Resources located in jimage file can be compressed. Compression occurs at
69 * jimage file creation time. When compressed a resource is added an header that
70 * contains the name of the compressor that compressed it.
71 * Various compression strategies can be applied to compress a resource.
72 * The same resource can even be compressed multiple time by a stack of compressors.
73 * At runtime, a resource is decompressed in a loop until there is no more header
74 * meaning that the resource is equivalent to the not compressed resource.
75 * In each iteration, the name of the compressor located in the current header
76 * is used to retrieve the associated instance of ImageDecompressor.
77 * For example “zip” is the name of the compressor that compresses resources
78 * using the zip algorithm. The ZipDecompressor class name is also “zip”.
79 * ImageDecompressor instances are retrieved from a static array in which
80 * they are registered.
81 */
82 class ImageDecompressor {
83
84 private:
85 const char* _name;
86
87 /*
88 * Array of concrete decompressors. This array is used to retrieve the decompressor
89 * that can handle resource decompression.
90 */
91 static ImageDecompressor** _decompressors;
92 /**
93 * Num of decompressors
94 */
95 static int _decompressors_num;
96 /*
97 * Identifier of a decompressor. This name is the identification key to retrieve
98 * decompressor from a resource header.
|
57 /* magic bytes that identifies a compressed resource header*/
58 static const u4 resource_header_magic = 0xCAFEFAFA;
59 u4 _magic; // Resource header
60 u8 _size; // Resource size
61 u8 _uncompressed_size; // Expected uncompressed size
62 u4 _decompressor_name_offset; // Strings table decompressor offset
63 u4 _decompressor_config_offset; // Strings table config offset
64 u1 _is_terminal; // Last decompressor 1, otherwise 0.
65 };
66
67 /*
68 * Resources located in jimage file can be compressed. Compression occurs at
69 * jimage file creation time. When compressed a resource is added an header that
70 * contains the name of the compressor that compressed it.
71 * Various compression strategies can be applied to compress a resource.
72 * The same resource can even be compressed multiple time by a stack of compressors.
73 * At runtime, a resource is decompressed in a loop until there is no more header
74 * meaning that the resource is equivalent to the not compressed resource.
75 * In each iteration, the name of the compressor located in the current header
76 * is used to retrieve the associated instance of ImageDecompressor.
77 * For example "zip" is the name of the compressor that compresses resources
78 * using the zip algorithm. The ZipDecompressor class name is also "zip".
79 * ImageDecompressor instances are retrieved from a static array in which
80 * they are registered.
81 */
82 class ImageDecompressor {
83
84 private:
85 const char* _name;
86
87 /*
88 * Array of concrete decompressors. This array is used to retrieve the decompressor
89 * that can handle resource decompression.
90 */
91 static ImageDecompressor** _decompressors;
92 /**
93 * Num of decompressors
94 */
95 static int _decompressors_num;
96 /*
97 * Identifier of a decompressor. This name is the identification key to retrieve
98 * decompressor from a resource header.
|