]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/util/IOUtils.java
Implementing sending group messages with sender keys
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / util / IOUtils.java
index 3cc708d8708d8cd0e8a6062e833d50856fe466ad..eebe64512601fa5b99940f159d121befae544a93 100644 (file)
@@ -7,6 +7,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.file.Files;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.FileTime;
 import java.nio.file.attribute.PosixFilePermission;
 import java.nio.file.attribute.PosixFilePermissions;
 import java.util.EnumSet;
@@ -72,4 +74,14 @@ public class IOUtils {
             output.write(buffer, 0, read);
         }
     }
+
+    public static long getFileCreateTime(final File file) {
+        try {
+            BasicFileAttributes attr = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
+            FileTime fileTime = attr.creationTime();
+            return fileTime.toMillis();
+        } catch (IOException ex) {
+            return -1;
+        }
+    }
 }