use of java.nio.file.attribute.PosixFilePermission in project gradle by gradle.
the class ChmodBenchmark method createFileJava7SetPermissionsWhenNeeded.
@Benchmark
public void createFileJava7SetPermissionsWhenNeeded(Blackhole blackhole) throws IOException {
int incrementAndGet = counter.incrementAndGet();
Path file = Files.createFile(tempDirPath.resolve("file-" + incrementAndGet));
Set<PosixFilePermission> originalPermissions = Files.getPosixFilePermissions(file);
Set<PosixFilePermission> permissionsToSet;
if (incrementAndGet % 2 == 0) {
permissionsToSet = DEFAULT_JAVA7_FILE_PERMISSIONS;
} else {
permissionsToSet = WEIRD_JAVA7_FILE_PERMISSIONS;
}
// This should pass 50% of the time
if (!originalPermissions.equals(permissionsToSet)) {
Files.setPosixFilePermissions(file, permissionsToSet);
}
blackhole.consume(file);
}
Aggregations