NET_FTP2 Question
| From: | Ian Warner | Date: | Mon, 25 Sep 2006 04:06:52 +0000 |
| Subject: | NET_FTP2 Question | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-44044@lists.php.net to get a copy of this message | ||
Tobias
Just a question regarding the developemnt of NET FTP 2.
I am currently using NET FTP and was trying the recursive directory download.
As soon as it hits one file that exists it stops the recursion shouldnt it just pass that file by and carry on, and give a silent message.
This could be a great tool for syncronising Directories, but needs to check whether the files exists before downloading. I just wondered if you are implementing anything like this in FTP2 ?
If not I need to add this element into FTP
Simply commenting out the return error on the file loop does the trick, what would be nice is if it created $this->error, then I can echo this to the screen so I can see the outcome of the synchronisation.
Anyway hope I havent missed anything that enables this to be done already.
function getRecursive($remote_path, $local_path,
$overwrite = false, $mode = null)
{
$remote_path = $this->_construct_path($remote_path);
if (!$this->_check_dir($remote_path)) {
return $this->raiseError("Given remote-path '$remote_path' seems not to be a directory.", NET_FTP_ERR_REMOTEPATHNODIR);
}
if (!$this->_check_dir($local_path)) {
return $this->raiseError("Given local-path '$local_path' seems not to be a directory.", NET_FTP_ERR_LOCALPATHNODIR);
}
if (!@is_dir($local_path)) {
$res = @mkdir($local_path);
if (!$res) {
return $this->raiseError("Could not create dir '$local_path'", NET_FTP_ERR_CREATELOCALDIR_FAILED);
}
}
$dir_list = array();
$dir_list = $this->ls($remote_path, NET_FTP_DIRS_ONLY);
foreach ($dir_list as $dir_entry) {
if ($dir_entry['name'] != '.' && $dir_entry['name'] != '..') {
$remote_path_new = $remote_path.$dir_entry["name"]."/";
$local_path_new = $local_path.$dir_entry["name"]."/";
$result = $this->getRecursive($remote_path_new, $local_path_new, $overwrite, $mode);
if ($this->isError($result)) {
return $result;
}
}
}
$file_list = array();
$file_list = $this->ls($remote_path, NET_FTP_FILES_ONLY);
foreach ($file_list as $file_entry) {
$remote_file = $remote_path . $file_entry['name'];
$local_file = $local_path . $file_entry['name'];
$result = $this->get($remote_file, $local_file, $overwrite, $mode);
if ($this->isError($result)) {
// return $result;
}
}
return true;
}
Cheers
Ian