185 public AsynchronousFileChannel truncate(long size) throws IOException {
186 if (size < 0)
187 throw new IllegalArgumentException("Negative size");
188 if (!writing)
189 throw new NonWritableChannelException();
190 try {
191 begin();
192 if (size > nd.size(fdObj))
193 return this;
194 nd.truncate(fdObj, size);
195 } finally {
196 end();
197 }
198 return this;
199 }
200
201 @Override
202 public void force(boolean metaData) throws IOException {
203 try {
204 begin();
205 nd.force(fdObj, metaData);
206 } finally {
207 end();
208 }
209 }
210
211 // -- file locking --
212
213 /**
214 * Task that initiates locking operation and handles completion result.
215 */
216 private class LockTask<A> implements Runnable, Iocp.ResultHandler {
217 private final long position;
218 private final FileLockImpl fli;
219 private final PendingFuture<FileLock,A> result;
220
221 LockTask(long position,
222 FileLockImpl fli,
223 PendingFuture<FileLock,A> result)
224 {
225 this.position = position;
|
185 public AsynchronousFileChannel truncate(long size) throws IOException {
186 if (size < 0)
187 throw new IllegalArgumentException("Negative size");
188 if (!writing)
189 throw new NonWritableChannelException();
190 try {
191 begin();
192 if (size > nd.size(fdObj))
193 return this;
194 nd.truncate(fdObj, size);
195 } finally {
196 end();
197 }
198 return this;
199 }
200
201 @Override
202 public void force(boolean metaData) throws IOException {
203 try {
204 begin();
205 // Added parameter writable for AIX platform port (not used on Windows).
206 nd.force(fdObj, metaData, writing);
207 } finally {
208 end();
209 }
210 }
211
212 // -- file locking --
213
214 /**
215 * Task that initiates locking operation and handles completion result.
216 */
217 private class LockTask<A> implements Runnable, Iocp.ResultHandler {
218 private final long position;
219 private final FileLockImpl fli;
220 private final PendingFuture<FileLock,A> result;
221
222 LockTask(long position,
223 FileLockImpl fli,
224 PendingFuture<FileLock,A> result)
225 {
226 this.position = position;
|