Refactor #5580: Add new file&directory apis into FileUtils and test cases

This is for keeping the `isDirectoryExist` function clean