Add last modified to file

This commit is contained in:
Victor Shcherb 2013-01-28 01:46:15 +01:00 committed by Alexey Pelykh
parent 9c67acfaf1
commit ce1f76a3e9
2 changed files with 29 additions and 0 deletions

View File

@ -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<jlong>(st.st_mtim.tv_sec) * 1000) +
(static_cast<jlong>(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)
{

View File

@ -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;