Factored some code in FileUtils.