public int close(Closeable closeable) { clear(); try { closeable.close(); return 0; } catch (IOException ioe) { Errno errno = Helpers.errnoFromException(ioe); if (errno == null) { throw new RuntimeException("unknown IOException: " + ioe); } this.errno = errno; return -1; } }
public int close(Closeable closeable) { clear(); try { closeable.close(); return 0; } catch (IOException ioe) { Errno errno = Helpers.errnoFromException(ioe); if (errno == null) { throw new RuntimeException("unknown IOException: " + ioe); } this.errno = errno; return -1; } }
public int write(ChannelFD fd, byte[] bytes, int offset, int length, boolean nonblock) { clear(); // FIXME: don't allocate every time ByteBuffer tmp = ByteBuffer.wrap(bytes, offset, length); try { if (nonblock) { // TODO: figure out what nonblocking writes against atypical streams (files?) actually do // If we can't set the channel nonblocking, I'm not sure what we can do to // pretend the channel is nonblocking. } if (fd.chWrite == null) { errno = Errno.EACCES; return -1; } int written = fd.chWrite.write(tmp); if (written == 0 && length > 0) { // if it's a nonblocking write against a file and we've hit EOF, do EAGAIN if (nonblock) { errno = Errno.EAGAIN; return -1; } } return written; } catch (IOException ioe) { errno = Helpers.errnoFromException(ioe); error = ioe; return -1; } }
public int write(ChannelFD fd, byte[] bytes, int offset, int length, boolean nonblock) { clear(); // FIXME: don't allocate every time ByteBuffer tmp = ByteBuffer.wrap(bytes, offset, length); try { if (nonblock) { // TODO: figure out what nonblocking writes against atypical streams (files?) actually do // If we can't set the channel nonblocking, I'm not sure what we can do to // pretend the channel is nonblocking. } if (fd.chWrite == null) { errno = Errno.EACCES; return -1; } int written = fd.chWrite.write(tmp); if (written == 0 && length > 0) { // if it's a nonblocking write against a file and we've hit EOF, do EAGAIN if (nonblock) { errno = Errno.EAGAIN; return -1; } } return written; } catch (IOException ioe) { errno = Helpers.errnoFromException(ioe); error = ioe; return -1; } }
public int read(ChannelFD fd, byte[] target, int offset, int length, boolean nonblock) { clear();
public int read(ChannelFD fd, byte[] target, int offset, int length, boolean nonblock) { clear();
public Channel[] pipe() { clear(); try { Pipe pipe = Pipe.open(); Channel source = pipe.source(), sink = pipe.sink(); if (posix.isNative() && !Platform.IS_WINDOWS) { // set cloexec if possible int read = FilenoUtil.filenoFrom(source); int write = FilenoUtil.filenoFrom(sink); setCloexec(read, true); setCloexec(write, true); } return new Channel[]{source, sink}; } catch (IOException ioe) { errno = Helpers.errnoFromException(ioe); return null; } }
public Channel[] pipe() { clear(); try { Pipe pipe = Pipe.open(); Channel source = pipe.source(), sink = pipe.sink(); if (posix.isNative() && !Platform.IS_WINDOWS) { // set cloexec if possible int read = FilenoUtil.filenoFrom(source); int write = FilenoUtil.filenoFrom(sink); setCloexec(read, true); setCloexec(write, true); } return new Channel[]{source, sink}; } catch (IOException ioe) { errno = Helpers.errnoFromException(ioe); return null; } }
public long lseek(ChannelFD fd, long offset, int type) { clear();
public long lseek(ChannelFD fd, long offset, int type) { clear();