41 */ |
41 */ |
42 static final int IOV_MAX; |
42 static final int IOV_MAX; |
43 |
43 |
44 private IOUtil() { } // No instantiation |
44 private IOUtil() { } // No instantiation |
45 |
45 |
46 public static int write(FileDescriptor fd, ByteBuffer src, long position, |
46 static int write(FileDescriptor fd, ByteBuffer src, long position, |
47 NativeDispatcher nd) |
47 NativeDispatcher nd) |
48 throws IOException |
48 throws IOException |
49 { |
49 { |
50 return write(fd, src, position, false, -1, nd); |
50 return write(fd, src, position, false, -1, nd); |
51 } |
51 } |
52 |
52 |
53 public static int write(FileDescriptor fd, ByteBuffer src, long position, |
53 static int write(FileDescriptor fd, ByteBuffer src, long position, |
54 boolean directIO, int alignment, NativeDispatcher nd) |
54 boolean directIO, int alignment, NativeDispatcher nd) |
55 throws IOException |
55 throws IOException |
56 { |
56 { |
57 if (src instanceof DirectBuffer) { |
57 if (src instanceof DirectBuffer) { |
58 return writeFromNativeBuffer(fd, src, position, directIO, alignment, nd); |
58 return writeFromNativeBuffer(fd, src, position, directIO, alignment, nd); |
115 if (written > 0) |
115 if (written > 0) |
116 bb.position(pos + written); |
116 bb.position(pos + written); |
117 return written; |
117 return written; |
118 } |
118 } |
119 |
119 |
120 public static long write(FileDescriptor fd, ByteBuffer[] bufs, NativeDispatcher nd) |
120 static long write(FileDescriptor fd, ByteBuffer[] bufs, NativeDispatcher nd) |
121 throws IOException |
121 throws IOException |
122 { |
122 { |
123 return write(fd, bufs, 0, bufs.length, false, -1, nd); |
123 return write(fd, bufs, 0, bufs.length, false, -1, nd); |
124 } |
124 } |
125 |
125 |
126 public static long write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
126 static long write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
127 NativeDispatcher nd) |
127 NativeDispatcher nd) |
128 throws IOException |
128 throws IOException |
129 { |
129 { |
130 return write(fd, bufs, offset, length, false, -1, nd); |
130 return write(fd, bufs, offset, length, false, -1, nd); |
131 } |
131 } |
132 |
132 |
133 public static long write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
133 static long write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
134 boolean directIO, int alignment, NativeDispatcher nd) |
134 boolean directIO, int alignment, NativeDispatcher nd) |
135 throws IOException |
135 throws IOException |
136 { |
136 { |
137 IOVecWrapper vec = IOVecWrapper.get(length); |
137 IOVecWrapper vec = IOVecWrapper.get(length); |
138 |
138 |
214 } |
214 } |
215 } |
215 } |
216 } |
216 } |
217 } |
217 } |
218 |
218 |
219 public static int read(FileDescriptor fd, ByteBuffer dst, long position, |
219 static int read(FileDescriptor fd, ByteBuffer dst, long position, |
220 NativeDispatcher nd) |
220 NativeDispatcher nd) |
221 throws IOException |
221 throws IOException |
222 { |
222 { |
223 return read(fd, dst, position, false, -1, nd); |
223 return read(fd, dst, position, false, -1, nd); |
224 } |
224 } |
225 |
225 |
226 public static int read(FileDescriptor fd, ByteBuffer dst, long position, |
226 static int read(FileDescriptor fd, ByteBuffer dst, long position, |
227 boolean directIO, int alignment, NativeDispatcher nd) |
227 boolean directIO, int alignment, NativeDispatcher nd) |
228 throws IOException |
228 throws IOException |
229 { |
229 { |
230 if (dst.isReadOnly()) |
230 if (dst.isReadOnly()) |
231 throw new IllegalArgumentException("Read-only buffer"); |
231 throw new IllegalArgumentException("Read-only buffer"); |
278 if (n > 0) |
278 if (n > 0) |
279 bb.position(pos + n); |
279 bb.position(pos + n); |
280 return n; |
280 return n; |
281 } |
281 } |
282 |
282 |
283 public static long read(FileDescriptor fd, ByteBuffer[] bufs, NativeDispatcher nd) |
283 static long read(FileDescriptor fd, ByteBuffer[] bufs, NativeDispatcher nd) |
284 throws IOException |
284 throws IOException |
285 { |
285 { |
286 return read(fd, bufs, 0, bufs.length, false, -1, nd); |
286 return read(fd, bufs, 0, bufs.length, false, -1, nd); |
287 } |
287 } |
288 |
288 |
289 public static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
289 static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
290 NativeDispatcher nd) |
290 NativeDispatcher nd) |
291 throws IOException |
291 throws IOException |
292 { |
292 { |
293 return read(fd, bufs, offset, length, false, -1, nd); |
293 return read(fd, bufs, offset, length, false, -1, nd); |
294 } |
294 } |
295 |
295 |
296 public static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
296 static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
297 boolean directIO, int alignment, NativeDispatcher nd) |
297 boolean directIO, int alignment, NativeDispatcher nd) |
298 throws IOException |
298 throws IOException |
299 { |
299 { |
300 IOVecWrapper vec = IOVecWrapper.get(length); |
300 IOVecWrapper vec = IOVecWrapper.get(length); |
301 |
301 |