- if ( ! $recursive || ! $this->is_dir($file) ) {
- if ( ! function_exists('ftp_chmod') )
- return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
- return @ftp_chmod($this->link, $mode, $file);
- }
- //Is a directory, and we want recursive
- $filelist = $this->dirlist($file);
- foreach ( $filelist as $filename ) {
- $this->chmod($file . '/' . $filename, $mode, $recursive);
+ // chmod any sub-objects if recursive.
+ if ( $recursive && $this->is_dir($file) ) {
+ $filelist = $this->dirlist($file);
+ foreach ( (array)$filelist as $filename => $filemeta )
+ $this->chmod($file . '/' . $filename, $mode, $recursive);