Fixed FTP and SMB to use rmdir() when deleting folders

Some storages need to use different calls for deleting files or folders,
usually unlink() and rmdir().

Fixes #4532 (SMB dir deletion)
Fixes #5941 (FTP dir deletion)

Note that the extra is_dir() should be fast because it's read from the
stat cache.

Backport of d69243e
Add trailing slash in FTP root path when missing

Fixes #6093

Backport of 84f3dd15a63fb80f33e61f6056e142b0443329d5