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

Request #4013 Ignoring files and directories on creating an archive.
Submitted: 2005-03-31 08:13 UTC
From: roth at egotec dot com Assigned: mrook
Status: Closed Package: Archive_Tar
PHP Version: 5.0.3 OS: Linux
Roadmaps: 1.3.6    
Subscription  


 [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] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!