static <I extends DataItem, O extends DataIoTask<I>> boolean invokeCopy( final I fileItem, final O ioTask, final FileChannel srcChannel, final FileChannel dstChannel ) throws IOException { long countBytesDone = ioTask.getCountBytesDone(); final long contentSize = fileItem.size(); if(countBytesDone < contentSize && IoTask.Status.ACTIVE.equals(ioTask.getStatus())) { countBytesDone += srcChannel.transferTo( countBytesDone, contentSize - countBytesDone, dstChannel ); ioTask.setCountBytesDone(countBytesDone); } return countBytesDone >= contentSize; }
private void invokeCopy( final I fileItem, final O ioTask, final FileChannel srcChannel, final FileChannel dstChannel ) throws IOException { long countBytesDone = ioTask.getCountBytesDone(); final long contentSize = fileItem.size(); if(countBytesDone < contentSize && Status.ACTIVE.equals(ioTask.getStatus())) { countBytesDone += srcChannel.transferTo( countBytesDone, contentSize - countBytesDone, dstChannel ); ioTask.setCountBytesDone(countBytesDone); } if(countBytesDone == contentSize) { finishIoTask(ioTask); } }
static <I extends DataItem, O extends DataIoTask<I>> boolean invokeOverwrite( final I fileItem, final O ioTask, final FileChannel dstChannel ) throws IOException { long countBytesDone = ioTask.getCountBytesDone(); if(countBytesDone == 0) { dstChannel.position(countBytesDone); } final long fileSize = fileItem.size(); if(countBytesDone < fileSize && IoTask.Status.ACTIVE.equals(ioTask.getStatus())) { countBytesDone += fileItem.writeToFileChannel(dstChannel, fileSize - countBytesDone); ioTask.setCountBytesDone(countBytesDone); } return countBytesDone >= fileSize; } }
static <I extends DataItem, O extends DataIoTask<I>> boolean invokeCreate( final I fileItem, final O ioTask, final FileChannel dstChannel ) throws IOException { long countBytesDone = ioTask.getCountBytesDone(); final long contentSize = fileItem.size(); if(countBytesDone < contentSize && IoTask.Status.ACTIVE.equals(ioTask.getStatus())) { countBytesDone += fileItem.writeToFileChannel(dstChannel, contentSize - countBytesDone); ioTask.setCountBytesDone(countBytesDone); } return countBytesDone >= contentSize; }
private void invokeCreate( final I fileItem, final O ioTask, final FileChannel dstChannel ) throws IOException { long countBytesDone = ioTask.getCountBytesDone(); final long contentSize = fileItem.size(); if(countBytesDone < contentSize && Status.ACTIVE.equals(ioTask.getStatus())) { countBytesDone += fileItem.writeToFileChannel(dstChannel, contentSize - countBytesDone); ioTask.setCountBytesDone(countBytesDone); } if(countBytesDone == contentSize) { finishIoTask(ioTask); } }