예제 #1
0
 /**
  * List the contents of the prebuilt TAR files
  */
 public function test_tarcontent()
 {
     $dir = dirname(__FILE__) . '/tar';
     foreach (array('tar', 'tgz', 'tbz') as $ext) {
         $tar = new Tar();
         $file = "{$dir}/test.{$ext}";
         $tar->open($file);
         $content = $tar->contents();
         $this->assertCount(4, $content, "Contents of {$file}");
         $this->assertEquals('tar/testdata1.txt', $content[1]['filename'], "Contents of {$file}");
         $this->assertEquals(13, $content[1]['size'], "Contents of {$file}");
         $this->assertEquals('tar/foobar/testdata2.txt', $content[3]['filename'], "Contents of {$file}");
         $this->assertEquals(13, $content[1]['size'], "Contents of {$file}");
     }
 }
예제 #2
0
 if (!is_dir("../tmp/")) {
     mkdir("../tmp/");
 }
 if (!is_dir("../tmp/" . $r_id)) {
     mkdir("../tmp/" . $r_id);
 }
 $t_path = "../tmp/" . $r_id . '/control.tar.gz';
 if (file_exists($t_path)) {
     unlink($t_path);
 }
 $control_tar_handle = fopen($t_path, 'w');
 fputs($control_tar_handle, $control_c_raw_data[0][6]);
 fclose($control_tar_handle);
 $control_tar = new Tar();
 $control_tar->load($t_path);
 $control_array = $control_tar->contents();
 $control_data = $control_array['control']['data'];
 $plain_array = explode("\n", $control_data);
 foreach ($plain_array as $line) {
     if (strlen(trim(substr($line, 0, 1))) == 0) {
         $t_value = trim($line);
         $t_package[$t_key] .= "\n" . $t_value;
     } else {
         if (preg_match("#^Package|Source|Version|Priority|Section|Essential|Maintainer|Pre-Depends|Depends|Recommends|Suggests|Conflicts|Provides|Replaces|Enhances|Architecture|Filename|Size|Installed-Size|Description|Origin|Bugs|Name|Author|Homepage|Website|Depiction|Icon|Tag|Sponsor#", $line)) {
             preg_match("#^([^:]*?):(.*)#", $line, $t_matches);
             $t_key = trim($t_matches[1]);
             $t_value = trim($t_matches[2]);
             $t_package[$t_key] = $t_value;
         }
     }
 }