001: /*
002: * Copyright 2000-2002 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.nio.ch;
027:
028: import java.io.*;
029:
030: /**
031: * Allows different platforms to call different native methods
032: * for read and write operations.
033: */
034:
035: class FileDispatcher extends NativeDispatcher {
036:
037: static {
038: Util.load();
039: init();
040: }
041:
042: int read(FileDescriptor fd, long address, int len)
043: throws IOException {
044: return read0(fd, address, len);
045: }
046:
047: int pread(FileDescriptor fd, long address, int len, long position,
048: Object lock) throws IOException {
049: return pread0(fd, address, len, position);
050: }
051:
052: long readv(FileDescriptor fd, long address, int len)
053: throws IOException {
054: return readv0(fd, address, len);
055: }
056:
057: int write(FileDescriptor fd, long address, int len)
058: throws IOException {
059: return write0(fd, address, len);
060: }
061:
062: int pwrite(FileDescriptor fd, long address, int len, long position,
063: Object lock) throws IOException {
064: return pwrite0(fd, address, len, position);
065: }
066:
067: long writev(FileDescriptor fd, long address, int len)
068: throws IOException {
069: return writev0(fd, address, len);
070: }
071:
072: void close(FileDescriptor fd) throws IOException {
073: close0(fd);
074: }
075:
076: void preClose(FileDescriptor fd) throws IOException {
077: preClose0(fd);
078: }
079:
080: // -- Native methods --
081:
082: static native int read0(FileDescriptor fd, long address, int len)
083: throws IOException;
084:
085: static native int pread0(FileDescriptor fd, long address, int len,
086: long position) throws IOException;
087:
088: static native long readv0(FileDescriptor fd, long address, int len)
089: throws IOException;
090:
091: static native int write0(FileDescriptor fd, long address, int len)
092: throws IOException;
093:
094: static native int pwrite0(FileDescriptor fd, long address, int len,
095: long position) throws IOException;
096:
097: static native long writev0(FileDescriptor fd, long address, int len)
098: throws IOException;
099:
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: }
|