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

Bug #7270 rm_dir recursive
Submitted: 2006-03-31 12:47 UTC
From: fabio dot esposito at gmail dot com Assigned: jorrit
Status: Closed Package: Net_FTP (version 1.3.2)
PHP Version: 4.3.11 OS: Linux
Roadmaps: 1.3.3    
Subscription  


 [2006-03-31 12:47 UTC] fabio dot esposito at gmail dot com (Fabio Esposito)
Description: ------------ When we try to remove recursively a dir on a unix server this error appear: "Uninitialized string offset: 0" (on windows it works) Test script: --------------- We change your _rm_dir_recursive function as below (see "/**/" comments) and now the code works on any plataform function _rm_dir_recursive($dir) { if (substr($dir, (strlen($dir) - 1), 1) != "/") { return $this->raiseError("Directory name '$dir' is invalid, has to end with '/'", NET_FTP_ERR_REMOTEPATHNODIR); } $file_list = $this->_ls_files($dir); foreach ($file_list as $file) { $file = $dir.$file["name"]; $res = $this->rm($file); if ($this->isError($res)) { return $res; } } $dir_list = $this->_ls_dirs($dir); foreach ($dir_list as $new_dir) { /** * in past the test isn't the position 'name' of the array but the entire array and the loop never ends. now works fine * **/ if ($new_dir['name'] == '.' || $new_dir['name'] == '..') { continue; } $new_dir = $dir.$new_dir["name"]."/"; //echo $new_dir."<br/>"; $res = $this->_rm_dir_recursive($new_dir); if ($this->isError($res)) { return $res; } } $res = $this->_rm_dir($dir); if (PEAR::isError($res)) { return $res; } else { return true; } } Expected result: ---------------- remove recursively a directory Actual result: -------------- with the patch the script works fine

Comments

 [2007-11-24 19:50 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!