Path: blob/master/src/java.base/share/classes/sun/nio/ch/FileDispatcher.java
41159 views
/*1* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.nio.ch;2627import java.io.FileDescriptor;28import java.io.IOException;29import java.nio.channels.SelectableChannel;3031abstract class FileDispatcher extends NativeDispatcher {3233public static final int NO_LOCK = -1; // Failed to lock34public static final int LOCKED = 0; // Obtained requested lock35public static final int RET_EX_LOCK = 1; // Obtained exclusive lock36public static final int INTERRUPTED = 2; // Request interrupted3738/**39* Sets or reports this file's position40* If offset is -1, the current position is returned41* otherwise the position is set to offset.42*/43abstract long seek(FileDescriptor fd, long offset) throws IOException;4445abstract int force(FileDescriptor fd, boolean metaData) throws IOException;4647abstract int truncate(FileDescriptor fd, long size) throws IOException;4849abstract long size(FileDescriptor fd) throws IOException;5051abstract int lock(FileDescriptor fd, boolean blocking, long pos, long size,52boolean shared) throws IOException;5354abstract void release(FileDescriptor fd, long pos, long size)55throws IOException;5657/**58* Returns a dup of fd if a file descriptor is required for59* memory-mapping operations, otherwise returns an invalid60* FileDescriptor (meaning a newly allocated FileDescriptor)61*/62abstract FileDescriptor duplicateForMapping(FileDescriptor fd)63throws IOException;6465abstract boolean canTransferToDirectly(SelectableChannel sc);6667abstract boolean transferToDirectlyNeedsPositionLock();6869abstract int setDirectIO(FileDescriptor fd, String path);70}717273