- function exists($file) {
- $list = @ftp_nlist($this->link, $file);
- return !empty($list); //empty list = no file, so invert.
+ /**
+ * @access public
+ *
+ * @param string $file
+ * @return bool
+ */
+ public function exists( $file ) {
+ $path = dirname( $file );
+ $filename = basename( $file );
+
+ $file_list = @ftp_nlist( $this->link, '-a ' . $path );
+ if ( $file_list ) {
+ $file_list = array_map( 'basename', $file_list );
+ }
+
+ return $file_list && in_array( $filename, $file_list );