implement avian.Handler.ResourceInputStream.available

This commit is contained in:
Joel Dice 2010-09-17 16:11:04 -06:00
parent 93c9395f1d
commit 64e42da348
2 changed files with 18 additions and 1 deletions

View File

@ -63,6 +63,12 @@ public class Handler extends URLStreamHandler {
public static native void close(long peer) throws IOException;
public static native int available(long peer, int position);
public int available() {
return available(peer, position);
}
public int read() throws IOException {
if (peer != 0) {
int c = read(peer, position);

View File

@ -87,7 +87,7 @@ Avian_avian_SystemClassLoader_resourceExists
bool r = getFinder(t, loader)->exists(RUNTIME_ARRAY_BODY(n));
fprintf(stderr, "resource %s exists? %d\n", n, r);
// fprintf(stderr, "resource %s exists? %d\n", n, r);
return r;
} else {
@ -186,6 +186,17 @@ Avian_avian_resource_Handler_00024ResourceInputStream_open
}
}
extern "C" JNIEXPORT int64_t JNICALL
Avian_avian_resource_Handler_00024ResourceInputStream_available
(Thread*, object, uintptr_t* arguments)
{
int64_t peer; memcpy(&peer, arguments, 8);
int32_t position = arguments[2];
System::Region* region = reinterpret_cast<System::Region*>(peer);
return static_cast<jint>(region->length()) - position;
}
extern "C" JNIEXPORT int64_t JNICALL
Avian_avian_resource_Handler_00024ResourceInputStream_read__JI
(Thread*, object, uintptr_t* arguments)