aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/nio/channels/natFileChannelImpl.cc
blob: 8dbbd141e604625c81bf6766f1bb9be038b084b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// 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

#include <gnu/gcj/RawData.h>
#include <java/io/FileDescriptor.h>
#include <java/io/IOException.h>
#include <java/nio/ByteBuffer.h>
#include <java/nio/channels/FileChannel.h>
#include <java/nio/channels/FileChannelImpl.h>

jlong
java::nio::channels::FileChannelImpl::size ()
{
  return fd->getLength ();
}

jlong
java::nio::channels::FileChannelImpl::implPosition ()
{
  return fd->getFilePointer ();
}

java::nio::channels::FileChannel*
java::nio::channels::FileChannelImpl::implPosition (jlong newPosition)
{
  fd->seek (newPosition, ::java::io::FileDescriptor::SET, true);
  return this;
}

jint
java::nio::channels::FileChannelImpl::implRead (JArray<jbyte>* buffer,
                                                jint offset, jint len)
{
  return fd->read (buffer, offset, len);
}

jint
java::nio::channels::FileChannelImpl::implWrite (JArray<jbyte>* buffer,
                                                 jint offset, jint len)
{
  fd->write (buffer, offset, len);
  return len;
}

java::nio::channels::FileChannel*
java::nio::channels::FileChannelImpl::implTruncate (jlong size)
{
  fd->setLength (size);
  return this;
}

gnu::gcj::RawData*
java::nio::channels::FileChannelImpl::nio_mmap_file (jlong /*pos*/, jlong /*size*/,
                                                     jint /*mode*/)
{
  throw new ::java::io::IOException (JvNewStringUTF ("mmap not implemented"));
}

void
java::nio::channels::FileChannelImpl::nio_unmmap_file (gnu::gcj::RawData* /*address*/,
				                       jint /*size*/)
{
  throw new ::java::io::IOException (JvNewStringUTF ("munmap not implemented"));
}

void
java::nio::channels::FileChannelImpl::nio_msync (gnu::gcj::RawData* /*map_address*/,
                                                 jint /*length*/)
{
  throw new ::java::io::IOException (JvNewStringUTF ("msync not implemented"));
}