Created
June 21, 2019 13:37
-
-
Save bric3/8c47d89a048911fd78ae552d90ca2fdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/java --source 11 --add-opens java.base/sun.nio.fs=ALL-UNNAMED | |
import java.lang.invoke.MethodHandles; | |
import java.lang.invoke.MethodType; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.attribute.PosixFileAttributes; | |
public class FileBirth { | |
public static void main(String[] args) throws Throwable { | |
var unixNativeDispatcherClass = Class.forName("sun.nio.fs.UnixNativeDispatcher"); | |
var birthtimeSupported = MethodHandles.privateLookupIn(unixNativeDispatcherClass, MethodHandles.lookup()) | |
.findStatic(unixNativeDispatcherClass, | |
"birthtimeSupported", | |
MethodType.methodType(boolean.class)); | |
System.out.printf("birth-time supported: %s", birthtimeSupported.invoke()); | |
for (String arg : args) { | |
var attr = Files.readAttributes(Paths.get(arg), PosixFileAttributes.class); | |
System.out.println(attr.creationTime()); | |
System.out.println(attr.lastModifiedTime()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment