more system-specific tweaks for windows port

This commit is contained in:
Joel Dice 2007-10-24 10:24:02 -06:00
parent 0f1a9bc77e
commit 5bfd90cfed
4 changed files with 38 additions and 12 deletions

View File

@ -13,8 +13,16 @@
# include "windows.h"
#endif
#ifdef __MINGW32__
# define SO_PREFIX ""
#else
# define SO_PREFIX "lib"
#endif
#ifdef __APPLE__
# define SO_SUFFIX ".jnilib"
#elif defined WIN32
# define SO_SUFFIX ".dll"
#else
# define SO_SUFFIX ".so"
#endif
@ -34,19 +42,20 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jint code)
};
switch (code) {
#ifdef WIN32
case LineSeparator:
return e->NewStringUTF("\n");
return e->NewStringUTF("\r\n");
case FileSeparator:
return e->NewStringUTF("/");
#ifdef WIN32
return e->NewStringUTF("\\");
case OsName:
return e->NewStringUTF("Windows");
case JavaIoTmpdir: {
TCHAR buffer[MAX_PATH];
GetTempPath(MAX_PATH, buffer);
fprintf(stderr, "tmpdir: %s\n", buffer);
return e->NewStringUTF(buffer);
}
@ -55,6 +64,12 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jint code)
return e->NewString(reinterpret_cast<jchar*>(home), lstrlenW(home));
}
#else
case LineSeparator:
return e->NewStringUTF("\n");
case FileSeparator:
return e->NewStringUTF("/");
case OsName:
return e->NewStringUTF("posix");
@ -109,9 +124,9 @@ Java_java_lang_System_doMapLibraryName(JNIEnv* e, jclass, jstring name)
const char* chars = e->GetStringUTFChars(name, 0);
if (chars) {
unsigned nameLength = strlen(chars);
unsigned size = nameLength + 3 + sizeof(SO_SUFFIX);
unsigned size = sizeof(SO_PREFIX) + nameLength + sizeof(SO_SUFFIX);
char buffer[size];
snprintf(buffer, size, "lib%s" SO_SUFFIX, chars);
snprintf(buffer, size, SO_PREFIX "%s" SO_SUFFIX, chars);
r = e->NewStringUTF(buffer);
e->ReleaseStringUTFChars(name, chars);

View File

@ -1,6 +1,9 @@
package java.io;
public class File {
private static final String FileSeparator
= System.getProperty("file.separator");
static {
System.loadLibrary("natives");
}
@ -13,15 +16,15 @@ public class File {
}
public File(String parent, String child) {
this(parent + "/" + child);
this(parent + FileSeparator + child);
}
public File(File parent, String child) {
this(parent.getPath() + "/" + child);
this(parent.getPath() + FileSeparator + child);
}
public String getName() {
int index = path.lastIndexOf("/");
int index = path.lastIndexOf(FileSeparator);
if (index >= 0) {
return path.substring(index + 1);
} else {
@ -34,7 +37,7 @@ public class File {
}
public String getParent() {
int index = path.lastIndexOf("/");
int index = path.lastIndexOf(FileSeparator);
if (index >= 0) {
return path.substring(0, index);
} else {

View File

@ -520,6 +520,8 @@ Java_java_lang_Runtime_load(Thread* t, jclass, jstring name, jboolean mapName)
}
}
fprintf(stderr, "load %s; map name: %d\n", n, mapName);
System::Library* lib;
if (LIKELY(t->m->system->success
(t->m->system->load(&lib, n, mapName, t->m->libraries))))

View File

@ -26,9 +26,15 @@
# error "Unsupported architecture"
#endif
#ifdef __MINGW32__
# define SO_PREFIX ""
#else
# define SO_PREFIX "lib"
#endif
#ifdef __APPLE__
# define SO_SUFFIX ".jnilib"
#elseif defined __MINGW32__
#elif defined __MINGW32__
# define SO_SUFFIX ".dll"
#else
# define SO_SUFFIX ".so"