/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* File-descriptor based I/O utilities that are shared by NIO classes.
*/
class IOUtil {
/**
*/
static final int IOV_MAX;
throws IOException
{
if (src instanceof DirectBuffer)
// Substitute a native buffer
try {
// Do not update src until we see how many bytes were written
if (n > 0) {
// now update src
}
return n;
} finally {
}
}
throws IOException
{
int written = 0;
if (rem == 0)
return 0;
if (position != -1) {
} else {
}
if (written > 0)
return written;
}
throws IOException
{
}
throws IOException
{
boolean completed = false;
int iov_len = 0;
try {
// Iterate over buffers to populate native iovec array.
int i = offset;
if (rem > 0) {
// allocate shadow buffer to ensure I/O is done with direct buffer
if (!(buf instanceof DirectBuffer)) {
}
iov_len++;
}
i++;
}
if (iov_len == 0)
return 0L;
// Notify the buffers how many bytes were taken
long left = bytesWritten;
for (int j=0; j<iov_len; j++) {
if (left > 0) {
left -= n;
}
// return shadow buffers to buffer pool
}
completed = true;
return bytesWritten;
} finally {
// if an error occurred then clear refs to buffers and return any shadow
// buffers to cache
if (!completed) {
for (int j=0; j<iov_len; j++) {
}
}
}
}
throws IOException
{
if (dst.isReadOnly())
throw new IllegalArgumentException("Read-only buffer");
if (dst instanceof DirectBuffer)
// Substitute a native buffer
try {
if (n > 0)
return n;
} finally {
}
}
throws IOException
{
if (rem == 0)
return 0;
int n = 0;
if (position != -1) {
} else {
}
if (n > 0)
return n;
}
throws IOException
{
}
throws IOException
{
boolean completed = false;
int iov_len = 0;
try {
// Iterate over buffers to populate native iovec array.
int i = offset;
if (buf.isReadOnly())
throw new IllegalArgumentException("Read-only buffer");
if (rem > 0) {
// allocate shadow buffer to ensure I/O is done with direct buffer
if (!(buf instanceof DirectBuffer)) {
}
iov_len++;
}
i++;
}
if (iov_len == 0)
return 0L;
// Notify the buffers how many bytes were read
for (int j=0; j<iov_len; j++) {
if (left > 0) {
} else {
}
left -= n;
}
}
completed = true;
return bytesRead;
} finally {
// if an error occurred then clear refs to buffers and return any shadow
// buffers to cache
if (!completed) {
for (int j=0; j<iov_len; j++) {
}
}
}
}
return fd;
}
/**
* Returns two file descriptors for a pipe encoded in a long.
* The read end of the pipe is returned in the high 32 bits,
* while the write end is returned in the low 32 bits.
*/
throws IOException;
static native int iovMax();
static native int fdLimit();
static native void initIDs();
static {
// Note that IOUtil.initIDs is called from within Util.load.
}
}