Refactoring the file/dir copy helpers