Changeset 130
- Timestamp:
- 01/20/07 23:23:46 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/star/StarArchive.php
r118 r130 103 103 } 104 104 105 $this->writer->write(pack('a4c1i1a247', 105 $ids = array_keys($this->index); 106 $this->writer->write(pack('a4c1a8a243', 106 107 'star', 107 108 self::VERSION, 108 sizeof(array_keys($this->index)),109 (string) count($ids), 109 110 "\0" 110 111 ) … … 112 113 113 114 // write index 114 foreach ( array_keys($this->index)as $id) {115 $this->writer->write(pack('a80a 80a80i1i1a8',115 foreach ($ids as $id) { 116 $this->writer->write(pack('a80a72a80a8a8a8', 116 117 $id, 117 118 $this->index[$id]['basename'], 118 119 $this->index[$id]['path'], 119 $this->index[$id]['datasize'],120 $offset,120 (string) $this->index[$id]['datasize'], 121 (string) $offset, 121 122 "\0" 122 123 ) … … 126 127 127 128 // write index 128 foreach ( array_keys($this->index)as $id) {129 foreach ($ids as $id) { 129 130 $this->writer->write($this->index[$id]['payload']); 130 131 } trunk/src/main/php/net/stubbles/star/StarLoader.php
r94 r130 43 43 * @param string $archive archive to retrieve index for 44 44 * @return array 45 * @throws StarException 45 46 */ 46 47 public static function acquire($archive) 47 48 { 48 49 static $archives = array(); 50 if (file_exists($archive) == false) { 51 return array(); 52 } 53 49 54 if (isset($archives[$archive]) == false) { 50 55 $archives[$archive] = array(); … … 52 57 53 58 $current['handle'] = fopen($archive, 'rb'); 54 if ( defined('__COMPILER_HALT_OFFSET__') == true) {59 if (__FILE__ == $archive && defined('__COMPILER_HALT_OFFSET__') == true) { 55 60 fseek($current['handle'], __COMPILER_HALT_OFFSET__); 56 61 } else { … … 58 63 } 59 64 60 $header = @unpack('a4id/c1version/i1indexsize/a*reserved', fread($current['handle'], 0x0100));65 $header = unpack('a4id/c1version/a8indexsize/a*reserved', fread($current['handle'], 0x0100)); 61 66 if (false === $header) { 62 67 // invalid star file … … 64 69 } 65 70 66 for ($current['index'] = array(), $i = 0; $i < $header['indexsize']; $i++) { 67 $entry = unpack('a80id/a80filename/a80path/i1size/i1offset/a*reserved', 71 $current['index'] = array(); 72 for ($i = 0; $i < $header['indexsize']; $i++) { 73 $entry = unpack('a80id/a72filename/a80path/a8size/a8offset/a*reserved', 68 74 fread($current['handle'], 0x0100) 69 75 ); 70 76 71 $current['index'][$entry['id']]= array('size' => $entry['size'], 'offset' =>$entry['offset']);77 $current['index'][$entry['id']]= array('size' => (int) $entry['size'], 'offset' => (int) $entry['offset']); 72 78 } 73 79 }
