2003-02-13 16:12:36 +01:00
|
|
|
// natFileChannelImpl.cc
|
|
|
|
|
|
|
|
/* Copyright (C) 2003 Free Software Foundation
|
|
|
|
|
|
|
|
This file is part of libgcj.
|
|
|
|
|
|
|
|
This software is copyrighted work licensed under the terms of the
|
|
|
|
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <jvm.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_FCNTL_H
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
2003-03-20 12:14:35 +01:00
|
|
|
#include <gnu/gcj/RawData.h>
|
2003-03-02 16:57:13 +01:00
|
|
|
#include <java/io/FileDescriptor.h>
|
2003-02-13 16:12:36 +01:00
|
|
|
#include <java/io/IOException.h>
|
2003-05-02 07:35:57 +02:00
|
|
|
#include <java/nio/ByteBuffer.h>
|
2003-02-13 16:12:36 +01:00
|
|
|
#include <java/nio/channels/FileChannel.h>
|
2003-07-13 18:53:05 +02:00
|
|
|
#include <java/nio/channels/FileChannelImpl.h>
|
2003-02-13 16:12:36 +01:00
|
|
|
|
|
|
|
jlong
|
2003-07-13 18:53:05 +02:00
|
|
|
java::nio::channels::FileChannelImpl::size ()
|
2003-02-13 16:12:36 +01:00
|
|
|
{
|
2003-05-13 11:13:31 +02:00
|
|
|
return fd->getLength ();
|
2003-02-13 16:12:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
jlong
|
2003-07-13 18:53:05 +02:00
|
|
|
java::nio::channels::FileChannelImpl::implPosition ()
|
2003-03-02 16:57:13 +01:00
|
|
|
{
|
|
|
|
return fd->getFilePointer ();
|
|
|
|
}
|
|
|
|
|
|
|
|
java::nio::channels::FileChannel*
|
2003-07-13 18:53:05 +02:00
|
|
|
java::nio::channels::FileChannelImpl::implPosition (jlong newPosition)
|
2003-03-02 16:57:13 +01:00
|
|
|
{
|
|
|
|
fd->seek (newPosition, ::java::io::FileDescriptor::SET, true);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2003-05-02 07:35:57 +02:00
|
|
|
jint
|
2003-07-13 18:53:05 +02:00
|
|
|
java::nio::channels::FileChannelImpl::implRead (JArray<jbyte>* buffer,
|
|
|
|
jint offset, jint len)
|
2003-05-02 07:35:57 +02:00
|
|
|
{
|
|
|
|
return fd->read (buffer, offset, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
jint
|
2003-07-13 18:53:05 +02:00
|
|
|
java::nio::channels::FileChannelImpl::implWrite (JArray<jbyte>* buffer,
|
|
|
|
jint offset, jint len)
|
2003-05-02 07:35:57 +02:00
|
|
|
{
|
|
|
|
fd->write (buffer, offset, len);
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2003-03-02 16:57:13 +01:00
|
|
|
java::nio::channels::FileChannel*
|
2003-07-13 18:53:05 +02:00
|
|
|
java::nio::channels::FileChannelImpl::implTruncate (jlong size)
|
2003-03-02 16:57:13 +01:00
|
|
|
{
|
|
|
|
fd->setLength (size);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2003-03-20 12:14:35 +01:00
|
|
|
gnu::gcj::RawData*
|
2003-07-13 18:53:05 +02:00
|
|
|
java::nio::channels::FileChannelImpl::nio_mmap_file (jlong /*pos*/, jlong /*size*/,
|
|
|
|
jint /*mode*/)
|
2003-02-13 16:12:36 +01:00
|
|
|
{
|
|
|
|
throw new ::java::io::IOException (JvNewStringUTF ("mmap not implemented"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-07-13 18:53:05 +02:00
|
|
|
java::nio::channels::FileChannelImpl::nio_unmmap_file (gnu::gcj::RawData* /*address*/,
|
|
|
|
jint /*size*/)
|
2003-02-13 16:12:36 +01:00
|
|
|
{
|
|
|
|
throw new ::java::io::IOException (JvNewStringUTF ("munmap not implemented"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-07-13 18:53:05 +02:00
|
|
|
java::nio::channels::FileChannelImpl::nio_msync (gnu::gcj::RawData* /*map_address*/,
|
|
|
|
jint /*length*/)
|
2003-02-13 16:12:36 +01:00
|
|
|
{
|
|
|
|
throw new ::java::io::IOException (JvNewStringUTF ("msync not implemented"));
|
|
|
|
}
|