public void read() { Memory old = getPointer(); Memory m = autoAllocate(size()); // horribly inefficient, but it'll do m.write(0, old.getByteArray(0, size()), 0, size()); useMemory(m); // Zero out the problematic callbacks for (field : problematic_fields) { m.setPointer(field_offset, null); } super.read(); useMemory(old); }
@Override public int read(byte[] b, int off, int len) throws IOException { int i = checkChannel(); if (i == -1) { return -1; } Memory m = new Memory(len); int read = library.ssh_channel_read(channel, m, len, stderr ? 1 : 0); if (read < 0) { throw new IOException("I/O Error"); } if(read == 0) { return -1; } byte[] buf = m.getByteArray(0, read); System.arraycopy(buf, 0, b, off, read); return read; }
private byte[] getBytesSockopt(int option) { Memory value = new Memory(1024); LongByReference length = new LongByReference(1024); zmq.zmq_getsockopt(ptr, option, value, length); return value.getByteArray(0, (int) length.getValue()); }
private byte[] getBytesSockopt(int option) { Memory value = new Memory(1024); LongByReference length = new LongByReference(1024); zmq.zmq_getsockopt(ptr, option, value, length); return value.getByteArray(0, (int) length.getValue()); }
private byte[] getBytesSockopt(int option) { Memory value = new Memory(1024); LongByReference length = new LongByReference(1024); zmq.zmq_getsockopt(ptr, option, value, length); return value.getByteArray(0, (int) length.getValue()); }
private byte[] getBytesSockopt(int option) { Memory value = new Memory(1024); LongByReference length = new LongByReference(1024); zmq.zmq_getsockopt(ptr, option, value, length); return value.getByteArray(0, (int) length.getValue()); }
if (e.getErrorCode() != 22 || !Arrays.equals(buff, cpusetArray.getByteArray(0, cpuSetSizeInBytes))) { throw new IllegalStateException("sched_setaffinity((" + cpuSetSizeInBytes + ") , &(" + affinity + ") ) errorNo=" + e.getErrorCode(), e);
WinNT.REG_MULTI_SZ, data.getByteArray(0, size), size);
throw new IOException("I/O Error"); byte[] buf = m.getByteArray(0, read); fout.write(buf); fireFileTransferProgressed(remoteFilePath, destinationFile.getPath(), read);
if (!HidD_SetOutputReport(m_Handle, m_OutputReportMemory.getByteArray(0, length + 1), length + 1)) {
+ " bytes"); byte[] byteArray = readBuffer.getByteArray(0, actualLen); System.arraycopy(byteArray, 0, b, off, actualLen); return actualLen;
+ " bytes"); byte[] byteArray = readBuffer.getByteArray(0, actualLen); System.arraycopy(byteArray, 0, b, off, actualLen); return actualLen;
@Override public int read(byte[] b, int off, int len) throws IOException { Memory readBuffer = new Memory(len); WinBase.OVERLAPPED olap = new WinBase.OVERLAPPED(); olap.hEvent = readerWaitable; olap.write(); boolean immediate = API.ReadFile(handle, readBuffer, len, null, olap.getPointer()); if (!immediate) { int lastError = API.GetLastError(); if (lastError != WinError.ERROR_IO_PENDING) { throw new IOException("ReadFile() failed: " + lastError); } } IntByReference read = new IntByReference(); if (!API.GetOverlappedResult(handle, olap.getPointer(), read, true)) { int lastError = API.GetLastError(); throw new IOException("GetOverlappedResult() failed for read operation: " + lastError); } int actualLen = read.getValue(); byte[] byteArray = readBuffer.getByteArray(0, actualLen); System.arraycopy(byteArray, 0, b, off, actualLen); return actualLen; } }
byteData.getByteArray(0, lpcbData.getValue())); break;
byteData.getByteArray(0, lpcbData.getValue())); break;
case kEdsDataType_Int8_Array: //EdsInt8[] case kEdsDataType_UInt8_Array: //EdsUInt8[] return (T) memory.getByteArray( 0, size ); case kEdsDataType_Int16_Array: //EdsInt16[] case kEdsDataType_UInt16_Array: //EdsUInt16[]
result = new Long(byteData.getLong(0)); } else if (lpType.getValue() == WinNT.REG_BINARY) { result = byteData.getByteArray(0, lpcbData.getValue()); } else if ((lpType.getValue() == WinNT.REG_SZ) || (lpType.getValue() == WinNT.REG_EXPAND_SZ)) {
public void get(String path, OutputStream out) throws SshException { sftp_file_struct file; file = library.sftp_open(sftp, path, LibsshClient.O_RDONLY, 0); try { if (file == null) { throw new SshException(SshException.GENERAL, "Failed to open file. " + library.ssh_get_error(libSshSession.getPointer())); } Memory buf = new Memory(LibsshClient.SFTP_BUFFER_SIZE); int nbytes = library.sftp_read(file, buf, new NativeSize(buf.size())); while (nbytes > 0) { try { out.write(buf.getByteArray(0, nbytes)); } catch (IOException e) { throw new SshException(SshException.GENERAL, "Failed to write to target stream.", e); } nbytes = library.sftp_read(file, buf, new NativeSize(buf.size())); } if (nbytes < 0) { throw new SshException(SshException.GENERAL, "Failed to read remote file. " + library.ssh_get_error(libSshSession.getPointer())); } } finally { library.sftp_close(file); } }
result = byteData.getLong(0); } else if (lpType.getValue() == WinNT.REG_BINARY) { result = byteData.getByteArray(0, lpcbData.getValue()); } else if ((lpType.getValue() == WinNT.REG_SZ) || (lpType.getValue() == WinNT.REG_EXPAND_SZ)) {