fix archive extraction:
* call with the proper path * remove the quotes from the calls, they're already there * make ExtractFile non-recursive * force unzip extraction to overwrite existing files
This commit is contained in:
parent
7269275e5c
commit
c192607d51
|
@ -112,7 +112,7 @@ if ($formu) {
|
|||
|
||||
if ($actextract) {
|
||||
print _("extracting...");
|
||||
if ($bro->ExtractFile($file, $R)) {
|
||||
if ($bro->ExtractFile($R. '/' . $file, $R)) {
|
||||
print $err->errstr();
|
||||
print _("failed");
|
||||
} else {
|
||||
|
|
|
@ -423,7 +423,6 @@ class m_bro {
|
|||
function ExtractFile($file, $dest=null)
|
||||
{
|
||||
global $err;
|
||||
static $i=0, $ret;
|
||||
$file = $this->convertabsolute($file,0);
|
||||
if (is_null($dest)) {
|
||||
$dest = dirname($file);
|
||||
|
@ -436,26 +435,22 @@ class m_bro {
|
|||
}
|
||||
$file = escapeshellarg($file);
|
||||
$dest = escapeshellarg($dest);
|
||||
if ($i == 0) {
|
||||
#TODO new version of tar supports `tar xf ...` so there is no
|
||||
# need to specify the compression format
|
||||
exec("tar -xzf '$file' -C '$dest'", $void, $ret);
|
||||
} else if ($i == 1) {
|
||||
exec("tar -xjf '$file' -C '$dest'", $void, $ret);
|
||||
} else if ($i == 2) {
|
||||
exec("unzip '$file' -d '$dest'", $void, $ret);
|
||||
} else {
|
||||
$err->raise("bro","undefined extractiong error: %s", $ret);
|
||||
return $ret;
|
||||
exec("tar -xzf $file -C $dest", $void, $ret);
|
||||
if ($ret) {
|
||||
#print "tgz extraction failed, moving on to tbz\n";
|
||||
exec("tar -xjf $file -C $dest", $void, $ret);
|
||||
}
|
||||
if ($ret) {
|
||||
$cmd = "unzip -o $file -d $dest";
|
||||
#print "tbz extraction failed, moving on to zip: $cmd\n";
|
||||
exec($cmd, $void, $ret);
|
||||
}
|
||||
if ($ret) {
|
||||
$err->raise("bro","could not find a way to extract file %s, unsupported format?", $file);
|
||||
}
|
||||
|
||||
if ($ret) {
|
||||
$i++;
|
||||
$ret = $this->ExtractFile($file, $dest);
|
||||
if ($ret) {
|
||||
$err->raise("bro","could not find a way to extract file %s, unsupported format?", $file);
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue