Merge branch 'master' of oss.readytalk.com:/var/local/git/avian

This commit is contained in:
jet 2009-10-05 18:02:11 -06:00
commit 3ecb950d4c
6 changed files with 40 additions and 3 deletions

View File

@ -355,6 +355,27 @@ Java_java_io_File_delete(JNIEnv* e, jclass, jstring path)
} }
} }
extern "C" JNIEXPORT jboolean JNICALL
Java_java_io_File_rename(JNIEnv* e, jclass, jstring old, jstring new_)
{
const char* oldChars = e->GetStringUTFChars(old, 0);
const char* newChars = e->GetStringUTFChars(new_, 0);
if (oldChars) {
bool v;
if (newChars) {
v = rename(oldChars, newChars) == 0;
e->ReleaseStringUTFChars(new_, newChars);
} else {
v = false;
}
e->ReleaseStringUTFChars(old, oldChars);
return v;
} else {
return false;
}
}
extern "C" JNIEXPORT jboolean JNICALL extern "C" JNIEXPORT jboolean JNICALL
Java_java_io_File_isDirectory(JNIEnv* e, jclass, jstring path) Java_java_io_File_isDirectory(JNIEnv* e, jclass, jstring path)
{ {

View File

@ -521,15 +521,18 @@ class Pipe {
if (setBlocking(e, pipe[0], false)) { if (setBlocking(e, pipe[0], false)) {
setBlocking(e, pipe[1], false); setBlocking(e, pipe[1], false);
} }
open_ = true;
} }
void dispose() { void dispose() {
::close(pipe[0]); ::close(pipe[0]);
::close(pipe[1]); ::close(pipe[1]);
open_ = false;
} }
bool connected() { bool connected() {
return true; return open_;
} }
int reader() { int reader() {
@ -542,6 +545,7 @@ class Pipe {
private: private:
int pipe[2]; int pipe[2];
bool open_;
#endif #endif
}; };

View File

@ -35,6 +35,12 @@ public class File {
this(parent.getPath() + FileSeparator + child); this(parent.getPath() + FileSeparator + child);
} }
public static native boolean rename(String old, String new_);
public boolean renameTo(File newName) {
return rename(path, newName.path);
}
private static native boolean isDirectory(String path); private static native boolean isDirectory(String path);
public boolean isDirectory() { public boolean isDirectory() {

View File

@ -16,6 +16,8 @@ import java.nio.ByteBuffer;
public abstract class SelectableChannel implements Channel { public abstract class SelectableChannel implements Channel {
private SelectionKey key; private SelectionKey key;
abstract int socketFD();
public abstract SelectableChannel configureBlocking(boolean v) public abstract SelectableChannel configureBlocking(boolean v)
throws IOException; throws IOException;

View File

@ -23,6 +23,10 @@ public class ServerSocketChannel extends SelectableChannel {
return new ServerSocketChannel(); return new ServerSocketChannel();
} }
public int socketFD() {
return channel.socketFD();
}
public SelectableChannel configureBlocking(boolean v) throws IOException { public SelectableChannel configureBlocking(boolean v) throws IOException {
return channel.configureBlocking(v); return channel.configureBlocking(v);
} }

View File

@ -72,7 +72,7 @@ class SocketSelector extends Selector {
it.hasNext();) it.hasNext();)
{ {
SelectionKey key = it.next(); SelectionKey key = it.next();
SocketChannel c = (SocketChannel)key.channel(); SelectableChannel c = key.channel();
int socket = c.socketFD(); int socket = c.socketFD();
if (c.isOpen()) { if (c.isOpen()) {
key.readyOps(0); key.readyOps(0);
@ -88,7 +88,7 @@ class SocketSelector extends Selector {
if (r > 0) { if (r > 0) {
for (SelectionKey key : keys) { for (SelectionKey key : keys) {
SocketChannel c = (SocketChannel)key.channel(); SelectableChannel c = key.channel();
int socket = c.socketFD(); int socket = c.socketFD();
int ready = natUpdateReadySet(socket, key.interestOps(), state); int ready = natUpdateReadySet(socket, key.interestOps(), state);
key.readyOps(ready); key.readyOps(ready);