From 75c51bb5eca14399f62082c5d9d596b67ab55b25 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Thu, 11 Oct 2007 15:39:21 -0600 Subject: [PATCH] Added user.home system property --- classpath/java-lang.cpp | 14 ++++++++++++-- classpath/java/lang/System.java | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/classpath/java-lang.cpp b/classpath/java-lang.cpp index 87d28d5c21..dac022c5d2 100644 --- a/classpath/java-lang.cpp +++ b/classpath/java-lang.cpp @@ -1,3 +1,5 @@ +#include "math.h" +#include "stdlib.h" #include "sys/time.h" #include "time.h" #include "time.h" @@ -22,7 +24,8 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jint code) LineSeparator = 100, FileSeparator = 101, OsName = 102, - JavaIoTmpdir = 103 + JavaIoTmpdir = 103, + UserHome = 104 }; switch (code) { @@ -38,6 +41,14 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jint code) case JavaIoTmpdir: return e->NewStringUTF("/tmp"); + case UserHome: + return e->NewStringUTF("/home/scharff"); +#ifdef WIN32 + LPWSTR home = _wgetenv(L"USERPROFILE"); + return JvNewString(reinterpret_cast(home), lstrlenW(home)); +#else + return e->NewStringUTF(getenv("HOME")); +#endif default: throwNew(e, "java/lang/RuntimeException", 0); return 0; @@ -70,7 +81,6 @@ Java_java_lang_System_doMapLibraryName(JNIEnv* e, jclass, jstring name) return r; } -#include extern "C" JNIEXPORT jdouble JNICALL Java_java_lang_Math_floor(JNIEnv*, jclass, jdouble val) { diff --git a/classpath/java/lang/System.java b/classpath/java/lang/System.java index 1817392ee0..185524b0e7 100644 --- a/classpath/java/lang/System.java +++ b/classpath/java/lang/System.java @@ -15,6 +15,7 @@ public abstract class System { private static final int FileSeparator = 101; private static final int OsName = 102; private static final int JavaIoTmpdir = 103; + private static final int UserHome = 104; private static Property properties; @@ -50,6 +51,8 @@ public abstract class System { code = LineSeparator; } else if (name.equals("file.separator")) { code = FileSeparator; + } else if (name.equals("user.home")) { + code = UserHome; } else if (name.equals("os.name")) { code = OsName; }