blob: 335ac49b951cfa8ae43fc8aa9a7939f154cf8e05 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2002 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package sun.nio.ch;
27
28import java.io.*;
29
30/**
31 * Allows different platforms to call different native methods
32 * for read and write operations.
33 */
34
35class FileDispatcher extends NativeDispatcher
36{
37
38 static {
39 Util.load();
40 init();
41 }
42
43 int read(FileDescriptor fd, long address, int len) throws IOException {
44 return read0(fd, address, len);
45 }
46
47 int pread(FileDescriptor fd, long address, int len,
48 long position, Object lock) throws IOException {
49 return pread0(fd, address, len, position);
50 }
51
52 long readv(FileDescriptor fd, long address, int len) throws IOException {
53 return readv0(fd, address, len);
54 }
55
56 int write(FileDescriptor fd, long address, int len) throws IOException {
57 return write0(fd, address, len);
58 }
59
60 int pwrite(FileDescriptor fd, long address, int len,
61 long position, Object lock) throws IOException
62 {
63 return pwrite0(fd, address, len, position);
64 }
65
66 long writev(FileDescriptor fd, long address, int len)
67 throws IOException
68 {
69 return writev0(fd, address, len);
70 }
71
72 void close(FileDescriptor fd) throws IOException {
73 close0(fd);
74 }
75
76 void preClose(FileDescriptor fd) throws IOException {
77 preClose0(fd);
78 }
79
80 // -- Native methods --
81
82 static native int read0(FileDescriptor fd, long address, int len)
83 throws IOException;
84
85 static native int pread0(FileDescriptor fd, long address, int len,
86 long position) throws IOException;
87
88 static native long readv0(FileDescriptor fd, long address, int len)
89 throws IOException;
90
91 static native int write0(FileDescriptor fd, long address, int len)
92 throws IOException;
93
94 static native int pwrite0(FileDescriptor fd, long address, int len,
95 long position) throws IOException;
96
97 static native long writev0(FileDescriptor fd, long address, int len)
98 throws IOException;
99
100 static native void close0(FileDescriptor fd) throws IOException;
101
102 static native void preClose0(FileDescriptor fd) throws IOException;
103
104 static native void closeIntFD(int fd) throws IOException;
105
106 static native void init();
107
108}