3 ? $argv[3] : false); $gDependencies = array(); $lines = file($argv[1]); $lDepth = 0; $lTree = array(); $lStack = array( array("",array()) ); foreach($lines as $line) { $line = trim($line); // Directory if(preg_match('/^Dir\s+"([^"]+)"\s+{$/', $line, $matches)) { $new = array($matches[1], array()); array_push($lStack, $new); $lDepth ++; continue; } // End of a block if($line == "}") { $lDepth --; $lStack[$lDepth][1][] = array_pop($lStack); continue; } // File if(preg_match('/^File\s+"([^"]+)"\s+"([^"]+)"$/', $line, $matches)) { $lStack[$lDepth][1][] = array($matches[1], $matches[2]); $gDependencies[] = $matches[2]; continue; } echo "ERROR: $line\n"; exit(0); } function hd($fp) { //return "0x".str_pad( dechex(ord(fgetc($fp))), 8, "0", STR_PAD_LEFT ); $val = unpack("I", fread($fp, 4)); //print_r($val); exit -1; return "0x".dechex($val[1]); } function hd8($fp) { return "0x".str_pad( dechex(ord(fgetc($fp))), 2, "0", STR_PAD_LEFT ); } function ProcessFolder($prefix, $items) { global $gOutput; global $ACESSDIR, $ARCH; foreach($items as $i=>$item) { if(is_array($item[1])) { ProcessFolder("{$prefix}_{$i}", $item[1]); $gOutput .= "tInitRD_File {$prefix}_{$i}_entries[] = {\n"; foreach($item[1] as $j=>$child) { if($j) $gOutput .= ",\n"; $gOutput .= "\t{\"".addslashes($child[0])."\",&{$prefix}_{$i}_{$j}}"; } $gOutput .= "\n};\n"; $size = count($item[1]); $gOutput .= <<$child) { if($j) $gOutput .= ",\n"; $gOutput .= "\t{\"".addslashes($child[0])."\",&gInitRD_Files_{$j}}"; } $gOutput .= "\n};\n"; $nRootFiles = count($lStack[0][1]); $gOutput .= <<