Skip to content

Commit

Permalink
added checkExecutable() and getDebug() methods, thanks Robert!
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPGangsta committed Apr 4, 2012
1 parent 46628b6 commit 9ae302a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions SevenZipArchive.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
<?php

/**
* This class helps working with the command line version of 7zip (http://www.7-zip.org) to
* compress, decompress and verify archives of different formats.
*
* @author Michael Kliewe
* @author Robert Gnuschke, Alpha Team Systems & Consulting GmbH
* @copyright Michael Kliewe
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @link http://www.phpgangsta.de
* @link http://www.rgshops.de
*/

class SevenZipArchive
{
// formats for compression and decompression
Expand Down Expand Up @@ -41,6 +53,25 @@ class SevenZipArchive
protected $_archivePath;
protected $_filePath;
protected $_password;
protected $_debug;

public function checkExecutable()
{
if (!function_exists('shell_exec')) {
return false;
}
$ret = shell_exec($this->_executablePath);
if (strpos($ret, "7-Zip") === false) {
return false;
} else {
return true;
}
}

public function getDebug()
{
return $this->_debug;
}

public function setExecutablePath($path)
{
Expand Down Expand Up @@ -86,6 +117,7 @@ public function compress()
if (strpos($ret, 'Everything is Ok')!==false) { // compression was successful
return true;
} else {
$this->_debug = $ret;
return false;
}
}
Expand All @@ -104,6 +136,7 @@ public function decompress()
if (strpos($ret, 'Everything is Ok')!==false) { // decompression was successful
return true;
} else { // password wrong or bad integrity
$this->_debug = $ret;
return false;
}
}
Expand All @@ -120,6 +153,7 @@ public function verify()
if (strpos($ret, 'Everything is Ok')!==false) { // verification was successful
return true;
} else { // password wrong or bad integrity
$this->_debug = $ret;
return false;
}
}
Expand Down

0 comments on commit 9ae302a

Please sign in to comment.