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

Request #2271 New flag for _rm_dir_recursive to leave directory structure intact
Submitted: 2004-09-02 13:40 UTC
From: joern_h at gmx dot net Assigned: jorrit
Status: Closed Package: Net_FTP
PHP Version: 4.3.0 OS: Win2000
Roadmaps: 1.4.0a2    
Subscription  


 [2004-09-02 13:40 UTC] joern_h at gmx dot net
Description: ------------ I needed a feature to recursively delete all files but keeping the directory structure intact. A Patch is attached. Reproduce code: --------------- --- FTP.php.jh Wed Sep 1 18:38:15 2004 +++ ftp.php Thu Sep 2 11:39:41 2004 @@ -1139,19 +1139,20 @@ * * @access public * @param string $path The absolute or relative path to the file / directory. * @param bool $recursive (optional) + * @param bool $files_only (optional) leave directory structure intact, delete only files * @return mixed True on success, otherwise PEAR::Error * @see NET_FTP_ERR_DELETEFILE_FAILED, NET_FTP_ERR_DELETEDIR_FAILED, NET_FTP_ERR_REMOTEPATHNODIR */ - function rm($path, $recursive = false) + function rm($path, $recursive = false, $files_only = false) { $path = $this->_construct_path($path); if ($this->_check_dir($path)) { if ($recursive) { - return $this->_rm_dir_recursive($path); + return $this->_rm_dir_recursive($path, $files_only); } else { return $this->_rm_dir($path); } } else { @@ -1868,9 +1869,9 @@ * @return mixed True on success, otherwise PEAR::Error * @see NET_FTP_ERR_REMOTEPATHNODIR, NET_FTP_ERR_DELETEDIR_FAILED */ - function _rm_dir_recursive($dir) + function _rm_dir_recursive($dir, $files_only = false) { if (substr($dir, (strlen($dir) - 1), 1) != "/") { return $this->raiseError("Directory name '$dir' is invalid, has to end with '/'", NET_FTP_ERR_REMOTEPATHNODIR); } @@ -1884,14 +1885,16 @@ } $dir_list = $this->_ls_dirs($dir); foreach ($dir_list as $new_dir) { $new_dir = $dir.$new_dir["name"]."/"; - $res = $this->_rm_dir_recursive($new_dir); + $res = $this->_rm_dir_recursive($new_dir, $files_only); if ($this->isError($res)) { return $res; } } - $res = $this->_rm_dir($dir); + if (!$files_only) { + $res = $this->_rm_dir($dir); + } if (!$res) { return $res; } else { return true;

Comments

 [2004-09-06 18:14 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!
 [2004-09-07 18:14 UTC] joern_h at gmx dot net
FTP.php says it is Net_FTP Version 1.3 $Id: FTP.php,v 1.26 2004/06/14 22:26:48 toby Exp $ I haven't worked with the pear bugtracker or with patches before so if you need more information or another patch format please tell me.
 [2004-09-22 17:29 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!
 [2005-01-04 21:05 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!
 [2008-04-22 22:10 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!
 [2008-05-19 19:28 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!