0N/A/*
3261N/A * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.nio.ch;
0N/A
0N/Aimport java.io.*;
2984N/Aimport sun.misc.SharedSecrets;
2984N/Aimport sun.misc.JavaIOFileDescriptorAccess;
0N/A
893N/Aclass FileDispatcherImpl extends FileDispatcher
0N/A{
0N/A static {
0N/A Util.load();
0N/A }
0N/A
3200N/A /**
3200N/A * Indicates if the dispatcher should first advance the file position
3200N/A * to the end of file when writing.
3200N/A */
3200N/A private final boolean append;
3200N/A
3200N/A FileDispatcherImpl(boolean append) {
3200N/A this.append = append;
3200N/A }
3200N/A
3200N/A FileDispatcherImpl() {
3200N/A this(false);
3200N/A }
3200N/A
6050N/A @Override
6050N/A boolean needsPositionLock() {
6050N/A return true;
6050N/A }
6050N/A
0N/A int read(FileDescriptor fd, long address, int len)
0N/A throws IOException
0N/A {
0N/A return read0(fd, address, len);
0N/A }
0N/A
6050N/A int pread(FileDescriptor fd, long address, int len, long position)
6050N/A throws IOException
0N/A {
6050N/A return pread0(fd, address, len, position);
0N/A }
0N/A
0N/A long readv(FileDescriptor fd, long address, int len) throws IOException {
0N/A return readv0(fd, address, len);
0N/A }
0N/A
0N/A int write(FileDescriptor fd, long address, int len) throws IOException {
3200N/A return write0(fd, address, len, append);
0N/A }
0N/A
6050N/A int pwrite(FileDescriptor fd, long address, int len, long position)
6050N/A throws IOException
0N/A {
6050N/A return pwrite0(fd, address, len, position);
0N/A }
0N/A
0N/A long writev(FileDescriptor fd, long address, int len) throws IOException {
3200N/A return writev0(fd, address, len, append);
0N/A }
0N/A
893N/A int force(FileDescriptor fd, boolean metaData) throws IOException {
893N/A return force0(fd, metaData);
893N/A }
893N/A
893N/A int truncate(FileDescriptor fd, long size) throws IOException {
893N/A return truncate0(fd, size);
893N/A }
893N/A
893N/A long size(FileDescriptor fd) throws IOException {
893N/A return size0(fd);
893N/A }
893N/A
893N/A int lock(FileDescriptor fd, boolean blocking, long pos, long size,
893N/A boolean shared) throws IOException
893N/A {
893N/A return lock0(fd, blocking, pos, size, shared);
893N/A }
893N/A
893N/A void release(FileDescriptor fd, long pos, long size) throws IOException {
893N/A release0(fd, pos, size);
893N/A }
893N/A
0N/A void close(FileDescriptor fd) throws IOException {
0N/A close0(fd);
0N/A }
0N/A
2984N/A FileDescriptor duplicateForMapping(FileDescriptor fd) throws IOException {
2984N/A // on Windows we need to keep a handle to the file
2984N/A JavaIOFileDescriptorAccess fdAccess =
2984N/A SharedSecrets.getJavaIOFileDescriptorAccess();
2984N/A FileDescriptor result = new FileDescriptor();
2984N/A long handle = duplicateHandle(fdAccess.getHandle(fd));
2984N/A fdAccess.setHandle(result, handle);
2984N/A return result;
2984N/A }
2984N/A
0N/A //-- Native methods
0N/A
0N/A static native int read0(FileDescriptor fd, long address, int len)
0N/A throws IOException;
0N/A
0N/A static native int pread0(FileDescriptor fd, long address, int len,
0N/A long position) throws IOException;
0N/A
0N/A static native long readv0(FileDescriptor fd, long address, int len)
0N/A throws IOException;
0N/A
3200N/A static native int write0(FileDescriptor fd, long address, int len, boolean append)
0N/A throws IOException;
0N/A
0N/A static native int pwrite0(FileDescriptor fd, long address, int len,
0N/A long position) throws IOException;
0N/A
3200N/A static native long writev0(FileDescriptor fd, long address, int len, boolean append)
0N/A throws IOException;
0N/A
893N/A static native int force0(FileDescriptor fd, boolean metaData)
893N/A throws IOException;
893N/A
893N/A static native int truncate0(FileDescriptor fd, long size)
893N/A throws IOException;
893N/A
893N/A static native long size0(FileDescriptor fd) throws IOException;
893N/A
893N/A static native int lock0(FileDescriptor fd, boolean blocking, long pos,
893N/A long size, boolean shared) throws IOException;
893N/A
893N/A static native void release0(FileDescriptor fd, long pos, long size)
893N/A throws IOException;
893N/A
0N/A static native void close0(FileDescriptor fd) throws IOException;
0N/A
0N/A static native void closeByHandle(long fd) throws IOException;
0N/A
2984N/A static native long duplicateHandle(long fd) throws IOException;
0N/A}