Changeset 1238
- Timestamp:
- 01/15/08 01:49:21 (8 months ago)
- Files:
-
- trunk/build/star/compile-reader.ini (modified) (1 diff)
- trunk/build/star/compile-writer-archive.ini (modified) (1 diff)
- trunk/build/star/compile-writer-cli.ini (modified) (1 diff)
- trunk/src/main/php/org/stubbles/phing/tasks/stubStarWriterTask.php (modified) (4 diffs)
- trunk/src/main/php/org/stubbles/star/StarArchive.php (modified) (5 diffs)
- trunk/src/main/php/org/stubbles/star/StarConsole.php (modified) (4 diffs)
- trunk/src/main/php/org/stubbles/star/StarStreamWrapper.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/star/compile-reader.ini
r1210 r1238 11 11 title = "Stubbles Archive Reader" 12 12 package = "org::stubbles::star" 13 version = "0. 6.0"13 version = "0.7.0" 14 14 author = "Stubbles Development Team <http://stubbles.net> 15 15 copyright = "© 2007-2008 Stubbles Development Team" trunk/build/star/compile-writer-archive.ini
r1210 r1238 15 15 title = "Stubbles Archive Writer" 16 16 package = "org::stubbles::star" 17 version = "0. 6.0"17 version = "0.7.0" 18 18 author = "Stubbles Development Team <http://stubbles.net> 19 19 copyright = "© 2007-2008 Stubbles Development Team" trunk/build/star/compile-writer-cli.ini
r1210 r1238 16 16 title = "Stubbles Archive CLI Writer" 17 17 package = "org::stubbles::star" 18 version = "0. 6.0"18 version = "0.7.0" 19 19 author = "Stubbles Development Team <http://stubbles.net> 20 20 copyright = "© 2007-2008 Stubbles Development Team" trunk/src/main/php/org/stubbles/phing/tasks/stubStarWriterTask.php
r1218 r1238 64 64 protected $preface = null; 65 65 /** 66 * the version of the starfile to build 67 * 68 * @var int 69 */ 70 protected $starVersion = 2; 71 /** 66 72 * the path to put the star archive into 67 73 * … … 146 152 { 147 153 $this->preface = $preface; 154 } 155 156 /** 157 * sets the star version number 158 * 159 * @param string $starVersion 160 */ 161 public function setStarVersion($starVersion) 162 { 163 $this->starVersion = $starVersion; 148 164 } 149 165 … … 205 221 206 222 // works now with refactored buildfile 207 /*223 208 224 $decorators = array(); 209 225 foreach ($this->decorators as $decorator) { 210 226 $decorators[$decorator->getStarId()] = $decorator; 211 227 } 212 */213 214 $starArchive = new StarArchive(new StarWriter($this->buildPath) );228 229 230 $starArchive = new StarArchive(new StarWriter($this->buildPath), $this->starVersion); 215 231 foreach($this->filesets as $fs) { 216 232 try { … … 240 256 241 257 $this->log('Adding ' . $fullFileName . ' as ' . $id); 242 if (isset($decorators[$id]) == false) {258 if (isset($decorators[$id]) === false) { 243 259 $starFile = new StarFile($fullFileName, $this->baseSrcPath); 244 260 } else { trunk/src/main/php/org/stubbles/star/StarArchive.php
r235 r1238 50 50 protected $metadata = array(); 51 51 /** 52 * star archive version 53 */ 54 const VERSION = 1; 52 * star archive version to create 53 * 54 * @var int 55 */ 56 protected $version = 2; 55 57 56 58 /** … … 59 61 * @param StarWriter $writer writer to use 60 62 */ 61 public function __construct(StarWriter $writer )63 public function __construct(StarWriter $writer, $version = 2) 62 64 { 63 65 $this->writer = $writer; 64 66 $this->writer->setExtension('star'); 67 $this->version = $version; 65 68 } 66 69 … … 137 140 $this->writer->write(pack('a4c1a8a14a229', 138 141 'star', 139 self::VERSION,142 $this->version, 140 143 (string) count($ids), 141 144 date('YmdHis'), … … 146 149 // write index 147 150 foreach ($ids as $id) { 148 $this->writer->write(pack('a80a72a80a8a8a8', 149 $id, 150 $this->index[$id]['basename'], 151 $this->index[$id]['path'], 152 (string) $this->index[$id]['datasize'], 153 (string) $offset, 154 "\0" 155 ) 156 ); 151 $this->writer->write($this->getHeader($id, $offset)); 157 152 $offset += $this->index[$id]['datasize']; 158 153 } … … 172 167 $this->writer->close(); 173 168 } 169 170 /** 171 * returns the header of entries depending on requested version 172 * 173 * @param string $id id of entry to create header data for 174 * @param int $offset offset where entry is located in file 175 * @return string 176 */ 177 protected function getHeader($id, $offset) 178 { 179 switch ($this->version) { 180 case 1: 181 $method = 'getHeaderForVersion1'; 182 break; 183 184 case 2: 185 default: 186 $method = 'getHeaderForVersion2'; 187 } 188 189 return $this->$method($id, $offset); 190 } 191 192 /** 193 * returns the header of entries for star files version 1 194 * 195 * @param string $id id of entry to create header data for 196 * @param int $offset offset where entry is located in file 197 * @return string 198 */ 199 protected function getHeaderForVersion1($id, $offset) 200 { 201 return pack('a80a72a80a8a8a8', $id, 202 $this->index[$id]['basename'], 203 $this->index[$id]['path'], 204 (string) $this->index[$id]['datasize'], 205 (string) $offset, 206 "\0" 207 ); 208 } 209 210 /** 211 * returns the header of entries for star files version 2 212 * 213 * @param string $id id of entry to create header data for 214 * @param int $offset offset where entry is located in file 215 * @return string 216 */ 217 protected function getHeaderForVersion2($id, $offset) 218 { 219 return pack('a232a8a8a8', $id, 220 (string) $this->index[$id]['datasize'], 221 (string) $offset, 222 "\0" 223 ); 224 } 174 225 } 175 226 ?> trunk/src/main/php/org/stubbles/star/StarConsole.php
r235 r1238 42 42 'default' => '' 43 43 ), 44 'star' => array('short' => 's', 45 'min' => 0, 46 'max' => 1, 47 'desc' => 'Star version to use: 1 or 2.', 48 'default' => '' 49 ), 44 50 'verbose' => array('short' => 'v', 45 51 'min' => 0, … … 66 72 */ 67 73 private $target; 74 /** 75 * star version to use 76 * 77 * @var int 78 */ 79 private $starVersion = 2; 68 80 69 81 /** … … 144 156 $this->target = $this->args->getValue('target'); 145 157 } 158 159 if ($this->args->isDefined('star') == true) { 160 $this->starVersion = $this->args->getValue('star'); 161 } 146 162 } 147 163 … … 164 180 $target = ((null == $this->target) ? ($conf['MAIN']['target']) : ($this->target)); 165 181 $this->verbose('Writing star data to ' . $target . "\n"); 166 $starArchive = new StarArchive(new StarWriter($target) );182 $starArchive = new StarArchive(new StarWriter($target), $this->starVersion); 167 183 $removePath = null; 168 184 if ($this->args->isDefined('removePath') == true) { trunk/src/main/php/org/stubbles/star/StarStreamWrapper.php
r614 r1238 103 103 } 104 104 105 if (1 === $header['version']) { 106 $key = 'a80id/a72filename/a80path/a8size/a8offset/a*reserved'; 107 } else { 108 $key = 'a232id/a8size/a8offset/a*reserved'; 109 } 110 105 111 for ($i = 0; $i < $header['indexsize']; $i++) { 106 $entry = unpack('a80id/a72filename/a80path/a8size/a8offset/a*reserved', 107 fread($current['handle'], 0x0100) 108 ); 109 112 $entry = unpack($key, fread($current['handle'], 0x0100)); 110 113 $current['index'][$entry['id']] = array('size' => (int) $entry['size'], 'offset' => (int) $entry['offset']); 111 114 $current['header']['totalSize'] += 0x0100 + ((int) $entry['size']);
