@@ -155,24 +155,28 @@ public function touch($files, $time = null, $atime = null)
155155 */
156156public function remove ($ files )
157157 {
158- $ files =iterator_to_array ($ this ->toIterator ($ files ));
158+ if ($ filesinstanceof \Traversable) {
159+ $ files =iterator_to_array ($ files ,false );
160+ }elseif (!is_array ($ files )) {
161+ $ files =array ($ files );
162+ }
159163$ files =array_reverse ($ files );
160164foreach ($ filesas $ file ) {
161- if (@(unlink ($ file ) ||rmdir ($ file ))) {
162- continue ;
163- }
164165if (is_link ($ file )) {
165166// See https://bugs.php.net/52176
166- $ error =error_get_last ();
167- throw new IOException (sprintf ('Failed to remove symlink "%s": %s. ' ,$ file ,$ error ['message ' ]));
167+ if (!@(unlink ($ file ) ||'\\' !==DIRECTORY_SEPARATOR ||rmdir ($ file )) &&file_exists ($ file )) {
168+ $ error =error_get_last ();
169+ throw new IOException (sprintf ('Failed to remove symlink "%s": %s. ' ,$ file ,$ error ['message ' ]));
170+ }
168171 }elseif (is_dir ($ file )) {
169- $ this ->remove (new \FilesystemIterator ($ file ));
170-
171172if (!@rmdir ($ file )) {
173+ $ this ->remove (new \FilesystemIterator ($ file , \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS ));
174+ }
175+ if (!@rmdir ($ file ) &&file_exists ($ file )) {
172176$ error =error_get_last ();
173177throw new IOException (sprintf ('Failed to remove directory "%s": %s. ' ,$ file ,$ error ['message ' ]));
174178 }
175- }elseif (file_exists ($ file )) {
179+ }elseif (!@ unlink ( $ file ) && file_exists ($ file )) {
176180$ error =error_get_last ();
177181throw new IOException (sprintf ('Failed to remove file "%s": %s. ' ,$ file ,$ error ['message ' ]));
178182 }