file: prevent replace failure when overwriting empty directory with hard or soft link on force=yes

Issue #7254 finalization (reopen) - empty directory replacement with a link was unable to be performed (Error while replacing: [Errno 21] Is a directory).