com.netflix.gradle.plugins.utils.JavaNIOUtils.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-ospackage-plugin Show documentation
Show all versions of gradle-ospackage-plugin Show documentation
Provides a task similar to Tar and Zip for constructing RPM and DEB package files.
package com.netflix.gradle.plugins.utils
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Path
final class JavaNIOUtils {
private JavaNIOUtils() {}
static Path createPath(String filePath) {
FileSystems.getDefault().getPath(filePath)
}
static boolean isSymbolicLink(File file) {
Path path = createPath(file.path)
Files.isSymbolicLink(path)
}
static File parentSymbolicLink(File file) {
File currentParent = file.parentFile
if (currentParent == null || isSymbolicLink(currentParent)) return currentParent else return parentSymbolicLink(currentParent)
}
static Path readSymbolicLink(Path path) {
Files.readSymbolicLink(path)
}
static void createSymbolicLink(File source, File target) {
Path newLink = createPath(source.path)
Path targetDir = createPath(target.path)
Files.createSymbolicLink(newLink, targetDir)
}
static Path createTempFile(String prefix, String suffix) {
return Files.createTempFile(prefix, suffix)
}
}