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.

Please review @schiesbn @karlitschek @icewind1991 @DeepDiver1975 

@icewind1991 the issues you mentioned previously related to making multiple calls to is_dir() won't cause performance issues as they are read from the stat cache (I've checked the smbclient calls)