Commit 1a4f6839 by Michael Koch Committed by Michael Koch

natFileChannelEcos.cc: Totally reworked.

2004-03-11  Michael Koch  <konqueror@gmx.de>

	* gnu/java/nio/channels/natFileChannelEcos.cc: Totally reworked.
	This file was was just copied form java/io/natFileDescriptorEcos.cc
	and never changed to compile correctly.

From-SVN: r79320
parent df8e2ad0
2004-03-11 Michael Koch <konqueror@gmx.de> 2004-03-11 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/channels/natFileChannelEcos.cc: Totally reworked.
This file was was just copied form java/io/natFileDescriptorEcos.cc
and never changed to compile correctly.
2004-03-11 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/PipeImpl.java * gnu/java/nio/PipeImpl.java
(SourceChannelImpl): Made final. (SourceChannelImpl): Made final.
(read): Implemented. (read): Implemented.
......
...@@ -26,37 +26,39 @@ details. */ ...@@ -26,37 +26,39 @@ details. */
#include <java/lang/NullPointerException.h> #include <java/lang/NullPointerException.h>
#include <java/lang/String.h> #include <java/lang/String.h>
#include <java/io/FileNotFoundException.h> #include <java/io/FileNotFoundException.h>
#include <java/nio/MappedByteBufferImpl.h>
extern "C" void diag_write_char (char c); #include <java/nio/channels/FileChannel.h>
#include <java/nio/channels/FileLock.h>
static void #include <gnu/java/nio/channels/FileChannelImpl.h>
diag_write (char *data, int len)
{ using gnu::gcj::RawData;
while (len > 0) using java::io::IOException;
{ using java::nio::MappedByteBufferImpl;
diag_write_char (*data++); using java::io::InterruptedIOException;
len--; using java::io::FileNotFoundException;
} using java::lang::ArrayIndexOutOfBoundsException;
} using java::lang::NullPointerException;
using gnu::java::nio::channels::FileChannelImpl;
#define NO_FSYNC_MESSAGE "sync unsupported" #define NO_FSYNC_MESSAGE "sync unsupported"
void void
java::io::FileDescriptor::init(void) FileChannelImpl::init(void)
{ {
in = new java::io::FileDescriptor(0); in = new FileChannelImpl((jint) 0, FileChannelImpl::READ);
out = new java::io::FileDescriptor(1); out = new FileChannelImpl((jint) 1, FileChannelImpl::WRITE);
err = new java::io::FileDescriptor(2); err = new FileChannelImpl((jint) 2, FileChannelImpl::WRITE);
} }
#if 0
jboolean jboolean
java::io::FileDescriptor::valid (void) FileChannelImpl::valid (void)
{ {
return true; return true;
} }
void void
java::io::FileDescriptor::sync (void) FileChannelImpl::sync (void)
{ {
// Some files don't support fsync. We don't bother reporting these // Some files don't support fsync. We don't bother reporting these
// as errors. // as errors.
...@@ -65,95 +67,110 @@ java::io::FileDescriptor::sync (void) ...@@ -65,95 +67,110 @@ java::io::FileDescriptor::sync (void)
throw new SyncFailedException (JvNewStringLatin1 (NO_FSYNC_MESSAGE)); throw new SyncFailedException (JvNewStringLatin1 (NO_FSYNC_MESSAGE));
#endif #endif
} }
#endif
jint jint
java::io::FileDescriptor::open (jstring path, jint jflags) FileChannelImpl::open (jstring, jint)
{ {
return fd; return fd;
} }
void void
java::io::FileDescriptor::write (jint b) FileChannelImpl::write (jint)
{ {
char d = (char) b;
::diag_write (&d, 1);
} }
void void
java::io::FileDescriptor::write (jbyteArray b, jint offset, jint len) FileChannelImpl::write (jbyteArray b, jint offset, jint len)
{ {
if (! b) if (! b)
throw new java::lang::NullPointerException; throw new NullPointerException;
if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b)) if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
throw new java::lang::ArrayIndexOutOfBoundsException; throw new ArrayIndexOutOfBoundsException;
char *bytes = (char *)elements (b) + offset;
::diag_write (bytes, len);
} }
void void
java::io::FileDescriptor::close (void) FileChannelImpl::implCloseChannel (void)
{ {
} }
void void
java::io::FileDescriptor::setLength (long) FileChannelImpl::implTruncate (jlong)
{ {
} }
jint void
java::io::FileDescriptor::seek (jlong pos, jint whence, jboolean) FileChannelImpl::seek (jlong)
{ {
JvAssert (whence == SET || whence == CUR);
return 0;
} }
jlong jlong
java::io::FileDescriptor::getLength (void) FileChannelImpl::size (void)
{ {
return 0; return 0;
} }
jlong jlong
java::io::FileDescriptor::getFilePointer (void) FileChannelImpl::implPosition (void)
{ {
return 0; return 0;
} }
jint jint
java::io::FileDescriptor::read (void) FileChannelImpl::read (void)
{ {
return 0; return 0;
} }
jint jint
java::io::FileDescriptor::read (jbyteArray buffer, jint offset, jint count) FileChannelImpl::read (jbyteArray buffer, jint offset, jint count)
{ {
return 0; return 0;
} }
jint jint
java::io::FileDescriptor::available (void) FileChannelImpl::available (void)
{ {
return 0; return 0;
} }
jboolean
FileChannelImpl::lock (jlong, jlong, jboolean, jboolean)
{
throw new IOException (JvNewStringLatin1
("gnu.java.nio.FileChannelImpl.lock() not implemented"));
}
void void
java::io::FileDescriptor::lock (jlong pos, jint len, jboolean shared) FileChannelImpl::unlock (jlong, jlong)
{ {
throw new IOException (JvNewStringLatin1 throw new IOException (JvNewStringLatin1
("java.io.FileDescriptor.lock() not implemented")); ("gnu.java.nio.channels.FileChannelImpl.unlock() not implemented"));
}
java::nio::MappedByteBuffer *
FileChannelImpl::mapImpl (jchar, jlong, jint)
{
return NULL;
}
void
MappedByteBufferImpl::unmapImpl ()
{
}
void
MappedByteBufferImpl::loadImpl ()
{
} }
jboolean jboolean
java::io::FileDescriptor::tryLock (jlong pos, jint len, jboolean shared) MappedByteBufferImpl::isLoadedImpl ()
{ {
throw new IOException (JvNewStringLatin1 return true;
("java.io.FileDescriptor.tryLock() not implemented"));
} }
void void
java::io::FileDescriptor::unlock (jlong pos, jint len) MappedByteBufferImpl::forceImpl ()
{ {
throw new IOException (JvNewStringLatin1
("java.io.FileDescriptor.unlock() not implemented"));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment