Implement something similar to Gradle internal API FileUtils.toSafeFileName.
FileUtils.toSafeFileName