jdk/src/windows/classes/sun/nio/ch/FileDispatcher.java
changeset 2079 425dfd4af0f8
parent 2078 4f3bb7d32ea0
parent 2077 fe36a2ff3c39
child 2081 38eb8733a4e4
equal deleted inserted replaced
2078:4f3bb7d32ea0 2079:425dfd4af0f8
     1 /*
       
     2  * Copyright 2000-2003 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 
       
    26 package sun.nio.ch;
       
    27 
       
    28 import java.io.*;
       
    29 
       
    30 
       
    31 /**
       
    32  * Allows different platforms to call different native methods
       
    33  * for read and write operations.
       
    34  */
       
    35 
       
    36 class FileDispatcher extends NativeDispatcher
       
    37 {
       
    38 
       
    39     static {
       
    40         Util.load();
       
    41     }
       
    42 
       
    43     int read(FileDescriptor fd, long address, int len)
       
    44         throws IOException
       
    45     {
       
    46         return read0(fd, address, len);
       
    47     }
       
    48 
       
    49     int pread(FileDescriptor fd, long address, int len,
       
    50                              long position, Object lock) throws IOException
       
    51     {
       
    52         synchronized(lock) {
       
    53             return pread0(fd, address, len, position);
       
    54         }
       
    55     }
       
    56 
       
    57     long readv(FileDescriptor fd, long address, int len) throws IOException {
       
    58         return readv0(fd, address, len);
       
    59     }
       
    60 
       
    61     int write(FileDescriptor fd, long address, int len) throws IOException {
       
    62         return write0(fd, address, len);
       
    63     }
       
    64 
       
    65     int pwrite(FileDescriptor fd, long address, int len,
       
    66                              long position, Object lock) throws IOException
       
    67     {
       
    68         synchronized(lock) {
       
    69             return pwrite0(fd, address, len, position);
       
    70         }
       
    71     }
       
    72 
       
    73     long writev(FileDescriptor fd, long address, int len) throws IOException {
       
    74         return writev0(fd, address, len);
       
    75     }
       
    76 
       
    77     void close(FileDescriptor fd) throws IOException {
       
    78         close0(fd);
       
    79     }
       
    80 
       
    81     //-- Native methods
       
    82 
       
    83     static native int read0(FileDescriptor fd, long address, int len)
       
    84         throws IOException;
       
    85 
       
    86     static native int pread0(FileDescriptor fd, long address, int len,
       
    87                              long position) throws IOException;
       
    88 
       
    89     static native long readv0(FileDescriptor fd, long address, int len)
       
    90         throws IOException;
       
    91 
       
    92     static native int write0(FileDescriptor fd, long address, int len)
       
    93         throws IOException;
       
    94 
       
    95     static native int pwrite0(FileDescriptor fd, long address, int len,
       
    96                              long position) throws IOException;
       
    97 
       
    98     static native long writev0(FileDescriptor fd, long address, int len)
       
    99         throws IOException;
       
   100 
       
   101     static native void close0(FileDescriptor fd) throws IOException;
       
   102 
       
   103     static native void closeByHandle(long fd) throws IOException;
       
   104 
       
   105 }