Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0

Request #4013 Ignoring files and directories on creating an archive.
Submitted: 2005-03-31 08:13 UTC
From: remi42 Assigned: mrook
Status: Closed Package: Archive_Tar
PHP Version: 5.0.3 OS: Linux
Roadmaps: 1.3.6    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
2010-03-09 14:35 UTC
Package:
Bug Type:
Summary:
From: roth at egotec dot com
New email:
PHP Version: Package Version: OS:

 

 [2005-03-31 08:13 UTC] roth at egotec dot com
Description: ------------ Version 1.3.1 I added the functionality to define a regular expression that describes files and directories that should be ignored when creating an archive with Archive_Tar. Full Downgrade compatibility. Patch: Index: Archive_Tar/Archive/Tar.php =================================================================== --- Archive_Tar/Archive/Tar.php (revision 11325) +++ Archive_Tar/Archive/Tar.php (working copy) @@ -62,6 +62,11 @@ */ var $_temp_tarname=''; + /** + * @var string regular expression for ignoring files or directories + */ + var $_ignore_regexp=''; + // {{{ constructor /** * Archive_Tar Class constructor. This flavour of the constructor only @@ -545,6 +550,36 @@ } // }}} + // {{{ setIgnoreRegexp() + /** + * This method sets the regular expression for ignoring files and directories + * at import, for example: + * $arch->setIgnoreRegexp("#CVS|\.svn#"); + * @param string $regexp regular expression defining which files or directories to ignore + * @access public + */ + function setIgnoreRegexp($regexp) + { + $this->_ignore_regexp = $regexp; + } + // }}} + + // {{{ setIgnoreList() + /** + * This method sets the regular expression for ignoring all files and directories + * matching the filenames in the array list at import, for example: + * $arch->setIgnoreList(array('CVS', '.svn', 'bin/tool')); + * @param array $list a list of file or directory names to ignore + * @access public + */ + function setIgnoreList($list) + { + $regexp = str_replace(array('#', '.', '^', '$'), array('\#', '\.', '\^', '\$'), $list); + $regexp = '#/'.join('$|/', $list).'#'; + $this->setIgnoreRegexp($regexp); + } + // }}} + // {{{ _error() function _error($p_message) { @@ -814,6 +849,12 @@ if ($v_filename == '') continue; + // ----- ignore files and directories matching the ignore regular expression + if ($this->_ignore_regexp && preg_match($this->_ignore_regexp, '/'.$v_filename)) { + $this->_warning("File '$v_filename' ignored"); + continue; + } + if (!file_exists($v_filename)) { $this->_warning("File '$v_filename' does not exist"); continue;

Comments

 [2010-03-09 14:35 UTC] mrook (Michiel Rook)
-Status: Open +Status: Closed -Assigned To: +Assigned To: mrook
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.