| 77 | | |
|---|
| 78 | | if (isset($archives[$archive]) == false) { |
|---|
| 79 | | $archives[$archive] = array(); |
|---|
| 80 | | $current =& $archives[$archive]; |
|---|
| 81 | | |
|---|
| 82 | | $current['handle'] = fopen($archive, 'rb'); |
|---|
| 83 | | if (__FILE__ == $archive && defined('__COMPILER_HALT_OFFSET__') == true) { |
|---|
| 84 | | fseek($current['handle'], __COMPILER_HALT_OFFSET__); |
|---|
| 85 | | } else { |
|---|
| 86 | | fseek($current['handle'], 0); |
|---|
| 87 | | } |
|---|
| 89 | | $header = unpack('a4id/c1version/a8indexsize/a14buildtime/a*reserved', fread($current['handle'], 0x0100)); |
|---|
| 90 | | if (false === $header) { |
|---|
| 91 | | // invalid star file |
|---|
| 92 | | return array(); |
|---|
| 93 | | } |
|---|
| | 83 | $current =& $archives[$archive]; |
|---|
| | 84 | $current['handle'] = fopen($archive, 'rb'); |
|---|
| | 85 | if (__FILE__ == $archive && defined('__COMPILER_HALT_OFFSET__') == true) { |
|---|
| | 86 | fseek($current['handle'], __COMPILER_HALT_OFFSET__); |
|---|
| | 87 | } else { |
|---|
| | 88 | fseek($current['handle'], 0); |
|---|
| | 89 | } |
|---|
| | 90 | |
|---|
| | 91 | $header = unpack('a4id/c1version/a8indexsize/a14buildtime/a*reserved', fread($current['handle'], 0x0100)); |
|---|
| | 92 | if (false === $header) { |
|---|
| | 93 | // invalid star file |
|---|
| | 94 | return array(); |
|---|
| | 95 | } |
|---|
| | 96 | |
|---|
| | 97 | $current['index'] = array(); |
|---|
| | 98 | $current['header'] = $header; |
|---|
| | 99 | if (__FILE__ == $archive && defined('__COMPILER_HALT_OFFSET__') == true) { |
|---|
| | 100 | $current['header']['totalSize'] = __COMPILER_HALT_OFFSET__ + 0x0100; |
|---|
| | 101 | } else { |
|---|
| | 102 | $current['header']['totalSize'] = 0x0100; |
|---|
| | 103 | } |
|---|
| | 104 | |
|---|
| | 105 | for ($i = 0; $i < $header['indexsize']; $i++) { |
|---|
| | 106 | $entry = unpack('a80id/a72filename/a80path/a8size/a8offset/a*reserved', |
|---|
| | 107 | fread($current['handle'], 0x0100) |
|---|
| | 108 | ); |
|---|
| 95 | | $current['index'] = array(); |
|---|
| 96 | | $current['header'] = $header; |
|---|
| 97 | | if (__FILE__ == $archive && defined('__COMPILER_HALT_OFFSET__') == true) { |
|---|
| 98 | | $current['header']['totalSize'] = __COMPILER_HALT_OFFSET__ + 0x0100; |
|---|
| 99 | | } else { |
|---|
| 100 | | $current['header']['totalSize'] = 0x0100; |
|---|
| 101 | | } |
|---|
| 102 | | for ($i = 0; $i < $header['indexsize']; $i++) { |
|---|
| 103 | | $entry = unpack('a80id/a72filename/a80path/a8size/a8offset/a*reserved', |
|---|
| 104 | | fread($current['handle'], 0x0100) |
|---|
| 105 | | ); |
|---|
| 106 | | |
|---|
| 107 | | $current['index'][$entry['id']] = array('size' => (int) $entry['size'], 'offset' => (int) $entry['offset']); |
|---|
| 108 | | $current['header']['totalSize'] += 0x0100 + ((int) $entry['size']); |
|---|
| 109 | | } |
|---|
| | 110 | $current['index'][$entry['id']] = array('size' => (int) $entry['size'], 'offset' => (int) $entry['offset']); |
|---|
| | 111 | $current['header']['totalSize'] += 0x0100 + ((int) $entry['size']); |
|---|