2003-03-02 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/FileChannelImpl.java (fd): Type FileDescriptor instead of int. (lengthInternal): Removed. (FileChannelImpl): Fixed arguments, check type of file object. (size): Made it native. (implPosition): New native method. (implTruncate): New native method. (position): Implemented. (truncate): Implemented. (nio_mmap_file): Changed arguments. (nio_munmap_file): Changed arguments. (nio_msync): Changed arguments. * gnu/java/nio/natFileChannelImpl.cc (lengthInternal): Removed. (size): New method. (implPosition): New method. (implTruncate): New method. (nio_mmap_file): Changed arguments. (nio_munmap_file): Changed arguments. (nio_msync): Changed arguments. From-SVN: r63668
This commit is contained in:
parent
05eb343676
commit
a339cb5bd9
3 changed files with 85 additions and 44 deletions
|
@ -1,3 +1,26 @@
|
||||||
|
2003-03-02 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
|
* gnu/java/nio/FileChannelImpl.java
|
||||||
|
(fd): Type FileDescriptor instead of int.
|
||||||
|
(lengthInternal): Removed.
|
||||||
|
(FileChannelImpl): Fixed arguments, check type of file object.
|
||||||
|
(size): Made it native.
|
||||||
|
(implPosition): New native method.
|
||||||
|
(implTruncate): New native method.
|
||||||
|
(position): Implemented.
|
||||||
|
(truncate): Implemented.
|
||||||
|
(nio_mmap_file): Changed arguments.
|
||||||
|
(nio_munmap_file): Changed arguments.
|
||||||
|
(nio_msync): Changed arguments.
|
||||||
|
* gnu/java/nio/natFileChannelImpl.cc
|
||||||
|
(lengthInternal): Removed.
|
||||||
|
(size): New method.
|
||||||
|
(implPosition): New method.
|
||||||
|
(implTruncate): New method.
|
||||||
|
(nio_mmap_file): Changed arguments.
|
||||||
|
(nio_munmap_file): Changed arguments.
|
||||||
|
(nio_msync): Changed arguments.
|
||||||
|
|
||||||
2003-03-02 Michael Koch <konqueror@gmx.de>
|
2003-03-02 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
* java/awt/dnd/DropTargetContext.java:
|
* java/awt/dnd/DropTargetContext.java:
|
||||||
|
|
|
@ -38,6 +38,7 @@ exception statement from your version. */
|
||||||
package gnu.java.nio;
|
package gnu.java.nio;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
|
import java.io.FileDescriptor;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -64,41 +65,41 @@ public class FileChannelImpl extends FileChannel
|
||||||
{
|
{
|
||||||
public long address;
|
public long address;
|
||||||
public int length;
|
public int length;
|
||||||
public int fd;
|
public FileDescriptor fd;
|
||||||
public MappedByteBuffer buf;
|
public MappedByteBuffer buf;
|
||||||
public Object file_obj; // just to keep it live...
|
public Object file_obj; // just to keep it live...
|
||||||
|
|
||||||
/**
|
public FileChannelImpl (FileDescriptor fd, boolean write, Object obj)
|
||||||
* This method came from java.io.RandomAccessFile
|
|
||||||
* It is private there so we will repeat it here.
|
|
||||||
*/
|
|
||||||
private native long lengthInternal (int native_fd) throws IOException;
|
|
||||||
|
|
||||||
public FileChannelImpl (int fd, Object obj)
|
|
||||||
{
|
{
|
||||||
|
if (!(obj instanceof RandomAccessFile)
|
||||||
|
&& !(obj instanceof FileInputStream)
|
||||||
|
&& !(obj instanceof FileOutputStream))
|
||||||
|
throw new InternalError ();
|
||||||
|
|
||||||
this.fd = fd;
|
this.fd = fd;
|
||||||
this.file_obj = obj;
|
this.file_obj = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long size () throws IOException
|
private native long implPosition ();
|
||||||
{
|
private native FileChannel implPosition (long newPosition);
|
||||||
if (!isOpen ())
|
private native FileChannel implTruncate (long size);
|
||||||
throw new ClosedChannelException ();
|
|
||||||
|
|
||||||
return lengthInternal (fd);
|
private native long nio_mmap_file (long pos, long size, int mode);
|
||||||
}
|
private native void nio_unmmap_file (long address, int size);
|
||||||
|
private native void nio_msync (long address, int length);
|
||||||
|
|
||||||
|
public native long size () throws IOException;
|
||||||
|
|
||||||
protected void implCloseChannel() throws IOException
|
protected void implCloseChannel() throws IOException
|
||||||
{
|
{
|
||||||
|
// FIXME
|
||||||
|
|
||||||
if (address != 0)
|
if (address != 0)
|
||||||
{
|
{
|
||||||
nio_unmmap_file (fd, address, (int) length);
|
//nio_unmmap_file (fd, address, (int) length);
|
||||||
address = 0;
|
address = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME
|
|
||||||
fd = 0;
|
|
||||||
|
|
||||||
if (file_obj instanceof RandomAccessFile)
|
if (file_obj instanceof RandomAccessFile)
|
||||||
{
|
{
|
||||||
RandomAccessFile o = (RandomAccessFile) file_obj;
|
RandomAccessFile o = (RandomAccessFile) file_obj;
|
||||||
|
@ -195,14 +196,14 @@ public class FileChannelImpl extends FileChannel
|
||||||
public long write(ByteBuffer[] srcs, int offset, int length)
|
public long write(ByteBuffer[] srcs, int offset, int length)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
long res = 0;
|
long result = 0;
|
||||||
|
|
||||||
for (int i = offset;i < offset + length;i++)
|
for (int i = offset;i < offset + length;i++)
|
||||||
{
|
{
|
||||||
res += write (srcs[i]);
|
result += write (srcs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MappedByteBuffer map (FileChannel.MapMode mode, long position,
|
public MappedByteBuffer map (FileChannel.MapMode mode, long position,
|
||||||
|
@ -252,7 +253,7 @@ public class FileChannelImpl extends FileChannel
|
||||||
|
|
||||||
// FIXME: What to do with metaData ?
|
// FIXME: What to do with metaData ?
|
||||||
|
|
||||||
nio_msync (fd, address, length);
|
nio_msync (address, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long transferTo (long position, long count, WritableByteChannel target)
|
public long transferTo (long position, long count, WritableByteChannel target)
|
||||||
|
@ -322,7 +323,7 @@ public class FileChannelImpl extends FileChannel
|
||||||
if (!isOpen ())
|
if (!isOpen ())
|
||||||
throw new ClosedChannelException ();
|
throw new ClosedChannelException ();
|
||||||
|
|
||||||
throw new Error ("not implemented");
|
return implPosition ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileChannel position (long newPosition)
|
public FileChannel position (long newPosition)
|
||||||
|
@ -334,7 +335,7 @@ public class FileChannelImpl extends FileChannel
|
||||||
if (!isOpen ())
|
if (!isOpen ())
|
||||||
throw new ClosedChannelException ();
|
throw new ClosedChannelException ();
|
||||||
|
|
||||||
throw new Error ("not implemented");
|
return implPosition (newPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileChannel truncate (long size)
|
public FileChannel truncate (long size)
|
||||||
|
@ -348,10 +349,6 @@ public class FileChannelImpl extends FileChannel
|
||||||
|
|
||||||
// FIXME: check for NonWritableChannelException
|
// FIXME: check for NonWritableChannelException
|
||||||
|
|
||||||
throw new Error ("not implemented");
|
return implTruncate (size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native long nio_mmap_file (int fd, long pos, int size, int mode);
|
|
||||||
private static native void nio_unmmap_file (int fd, long address, int size);
|
|
||||||
private static native void nio_msync (int fd, long address, int length);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,29 +25,50 @@ details. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gnu/java/nio/FileChannelImpl.h>
|
#include <gnu/java/nio/FileChannelImpl.h>
|
||||||
|
#include <java/io/FileDescriptor.h>
|
||||||
#include <java/io/IOException.h>
|
#include <java/io/IOException.h>
|
||||||
#include <java/nio/channels/FileChannel.h>
|
#include <java/nio/channels/FileChannel.h>
|
||||||
|
|
||||||
jlong
|
jlong
|
||||||
gnu::java::nio::FileChannelImpl::lengthInternal (jint fd)
|
gnu::java::nio::FileChannelImpl::size ()
|
||||||
{
|
{
|
||||||
throw new ::java::io::IOException (JvNewStringUTF ("lengthInternal not implemented"));
|
return fd->length ();
|
||||||
}
|
}
|
||||||
|
|
||||||
jlong
|
jlong
|
||||||
gnu::java::nio::FileChannelImpl::nio_mmap_file (jint, jlong, jint, jint)
|
gnu::java::nio::FileChannelImpl::implPosition ()
|
||||||
|
{
|
||||||
|
return fd->getFilePointer ();
|
||||||
|
}
|
||||||
|
|
||||||
|
java::nio::channels::FileChannel*
|
||||||
|
gnu::java::nio::FileChannelImpl::implPosition (jlong newPosition)
|
||||||
|
{
|
||||||
|
fd->seek (newPosition, ::java::io::FileDescriptor::SET, true);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
java::nio::channels::FileChannel*
|
||||||
|
gnu::java::nio::FileChannelImpl::implTruncate (jlong size)
|
||||||
|
{
|
||||||
|
fd->setLength (size);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
jlong
|
||||||
|
gnu::java::nio::FileChannelImpl::nio_mmap_file (jlong, jlong, jint)
|
||||||
{
|
{
|
||||||
throw new ::java::io::IOException (JvNewStringUTF ("mmap not implemented"));
|
throw new ::java::io::IOException (JvNewStringUTF ("mmap not implemented"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnu::java::nio::FileChannelImpl::nio_unmmap_file (jint, jlong, jint)
|
gnu::java::nio::FileChannelImpl::nio_unmmap_file (jlong, jint)
|
||||||
{
|
{
|
||||||
throw new ::java::io::IOException (JvNewStringUTF ("munmap not implemented"));
|
throw new ::java::io::IOException (JvNewStringUTF ("munmap not implemented"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnu::java::nio::FileChannelImpl::nio_msync (jint, jlong, jint)
|
gnu::java::nio::FileChannelImpl::nio_msync (jlong, jint)
|
||||||
{
|
{
|
||||||
throw new ::java::io::IOException (JvNewStringUTF ("msync not implemented"));
|
throw new ::java::io::IOException (JvNewStringUTF ("msync not implemented"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue