diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index db9882e051..c12ee64368 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -541,6 +541,28 @@ Java_java_io_File_openDir(JNIEnv* e, jclass, jstring path) } } +extern "C" JNIEXPORT jlong JNICALL +Java_java_io_File_lastModified(JNIEnv* e, jclass, jstring path) +{ + string_t chars = getChars(e, path); + if (chars) { + #ifdef PLATFORM_WINDOWS + # error "Implementation of last modified :)" + #else + struct stat st; + if (stat(chars, &st)) { + return 0; + } else { + return (static_cast(st.st_mtim.tv_sec) * 1000) + + (static_cast(st.st_mtim.tv_nsec) / (1000*1000)); + } + + #endif + } else { + return 0; + } +} + extern "C" JNIEXPORT jstring JNICALL Java_java_io_File_readDir(JNIEnv* e, jclass, jlong handle) { diff --git a/classpath/java/io/File.java b/classpath/java/io/File.java index b66aa03ff9..8eceed4b71 100644 --- a/classpath/java/io/File.java +++ b/classpath/java/io/File.java @@ -294,12 +294,19 @@ public class File implements Serializable { } } + public long lastModified() { + return lastModified(path); + } private static native long openDir(String path); + private static native long lastModified(String path); + private static native String readDir(long handle); private static native long closeDir(long handle); + + private static class Pair { public final String value; public final Pair next;