cvs: pear /Archive_Tar/Archive Tar.php
| From: | Vincent Blavet | Date: | Tue, 24 Jun 2003 21:14:35 +0000 |
| Subject: | cvs: pear /Archive_Tar/Archive Tar.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-11156@lists.php.net to get a copy of this message | ||
vblavet Tue Jun 24 17:14:35 2003 EDT
Modified files:
/pear/Archive_Tar/Archive Tar.php
Log:
- Add support for other file separator than the space char
- Add the method setAttribute() that will allow futur class attribute manipulation
Index: pear/Archive_Tar/Archive/Tar.php
diff -u pear/Archive_Tar/Archive/Tar.php:1.14 pear/Archive_Tar/Archive/Tar.php:1.15
--- pear/Archive_Tar/Archive/Tar.php:1.14 Wed Jun 18 17:34:53 2003
+++ pear/Archive_Tar/Archive/Tar.php Tue Jun 24 17:14:35 2003
@@ -16,15 +16,18 @@
// | Author: Vincent Blavet <vincent@blavet.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Tar.php,v 1.14 2003/06/18 21:34:53 vblavet Exp $
+// $Id: Tar.php,v 1.15 2003/06/24 21:14:35 vblavet Exp $
require_once 'PEAR.php';
+
+define ('ARCHIVE_TAR_ATT_SEPARATOR', 90001);
+
/**
* Creates a (compressed) Tar archive
*
* @author Vincent Blavet <vincent@blavet.net>
-* @version $Revision: 1.14 $
+* @version $Revision: 1.15 $
* @package Archive
*/
class Archive_Tar extends PEAR
@@ -45,6 +48,11 @@
var $_compress_type='none';
/**
+ * @var string Explode separator
+ */
+ var $_separator=' ';
+
+ /**
* @var file descriptor
*/
var $_file=0;
@@ -258,7 +266,7 @@
if (is_array($p_filelist))
$v_list = $p_filelist;
elseif (is_string($p_filelist))
- $v_list = explode(" ", $p_filelist);
+ $v_list = explode($this->_separator, $p_filelist);
else {
$this->_cleanFile();
$this->_error('Invalid file list');
@@ -326,7 +334,7 @@
if (is_array($p_filelist))
$v_list = $p_filelist;
elseif (is_string($p_filelist))
- $v_list = explode(" ", $p_filelist);
+ $v_list = explode($this->_separator, $p_filelist);
else {
$this->_error('Invalid file list');
return false;
@@ -469,7 +477,7 @@
if (is_array($p_filelist))
$v_list = $p_filelist;
elseif (is_string($p_filelist))
- $v_list = explode(" ", $p_filelist);
+ $v_list = explode($this->_separator, $p_filelist);
else {
$this->_error('Invalid string list');
return false;
@@ -478,6 +486,58 @@
if ($v_result = $this->_openRead()) {
$v_result = $this->_extractList($p_path, $v_list_detail, "partial",
$v_list, $p_remove_path);
$this->_close();
+ }
+
+ return $v_result;
+ }
+ // }}}
+
+ // {{{ setAttribute()
+ /**
+ * This method set specific attributes of the archive. It uses a variable
+ * list of parameters, in the format attribute code + attribute values :
+ * $arch->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ',');
+ * @return true on success, false on error.
+ * @access public
+ */
+ function setAttribute()
+ {
+ $v_result = true;
+
+ // ----- Get the number of variable list of arguments
+ if (($v_size = func_num_args()) == 0) {
+ return true;
+ }
+
+ // ----- Get the arguments
+ $v_att_list = &func_get_args();
+
+ // ----- Read the attributes
+ $i=0;
+ while ($i<$v_size) {
+
+ // ----- Look for next option
+ switch ($v_att_list[$i]) {
+ // ----- Look for options that request a string value
+ case ARCHIVE_TAR_ATT_SEPARATOR :
+ // ----- Check the number of parameters
+ if (($i+1) >= $v_size) {
+ $this->_error('Invalid number of parameters for attribute
ARCHIVE_TAR_ATT_SEPARATOR');
+ return false;
+ }
+
+ // ----- Get the value
+ $this->_separator = $v_att_list[$i+1];
+ $i++;
+ break;
+
+ default :
+ $this->_error('Unknow attribute code
'.$v_att_list[$i].'');
+ return false;
+ }
+
+ // ----- Next attribute
+ $i++;
}
return $v_result;