implement a few classpath methods required by SWT for Win32

This commit is contained in:
Joel Dice 2007-10-29 14:57:33 -06:00
parent 7aecdb6ce0
commit 75d4a4ff96
5 changed files with 34 additions and 0 deletions

View File

@ -163,6 +163,21 @@ Java_java_io_File_delete(JNIEnv* e, jclass, jstring path)
return r == 0;
}
extern "C" JNIEXPORT jboolean JNICALL
Java_java_io_File_isDirectory(JNIEnv* e, jclass, jstring path)
{
const char* chars = e->GetStringUTFChars(path, 0);
if (chars) {
STRUCT_STAT s;
int r = STAT(chars, &s);
bool v = (r == 0 and S_ISDIR(s.st_mode));
e->ReleaseStringUTFChars(path, chars);
return v;
} else {
return false;
}
}
extern "C" JNIEXPORT jboolean JNICALL
Java_java_io_File_exists(JNIEnv* e, jclass, jstring path)
{

View File

@ -23,6 +23,12 @@ public class File {
this(parent.getPath() + FileSeparator + child);
}
private static native boolean isDirectory(String path);
public boolean isDirectory() {
return isDirectory(path);
}
public String getName() {
int index = path.lastIndexOf(FileSeparator);
if (index >= 0) {

View File

@ -37,6 +37,10 @@ public final class Byte extends Number implements Comparable<Byte> {
return toString(v, 10);
}
public static byte parseByte(String s) {
return (byte) Integer.parseInt(s);
}
public byte byteValue() {
return value;
}

View File

@ -60,6 +60,8 @@ public class Runtime {
public native long freeMemory();
public native long totalMemory();
private static class MyProcess extends Process {
private int pid;
private final int in;

View File

@ -561,6 +561,13 @@ Java_java_lang_Runtime_freeMemory(Thread*, jobject)
return 0;
}
extern "C" JNIEXPORT jlong JNICALL
Java_java_lang_Runtime_totalMemory(Thread*, jobject)
{
// todo
return 0;
}
extern "C" JNIEXPORT jobject JNICALL
Java_java_lang_Throwable_trace(Thread* t, jclass, jint skipCount)
{