From f6e56b345d1e4af409760de19e6f475f06a591d6 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Tue, 17 Mar 2015 21:36:11 -0400 Subject: [PATCH] CB-8699 Fix CordovaResourceApi copyResource creating zero-length files when src=uncompressed asset --- framework/src/org/apache/cordova/CordovaResourceApi.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/src/org/apache/cordova/CordovaResourceApi.java b/framework/src/org/apache/cordova/CordovaResourceApi.java index 9c2e7080..47f936e8 100644 --- a/framework/src/org/apache/cordova/CordovaResourceApi.java +++ b/framework/src/org/apache/cordova/CordovaResourceApi.java @@ -336,7 +336,10 @@ public class CordovaResourceApi { if (input.assetFd != null) { offset = input.assetFd.getStartOffset(); } - outChannel.transferFrom(inChannel, offset, length); + // transferFrom()'s 2nd arg is a relative position. Need to set the absolute + // position first. + inChannel.position(offset); + outChannel.transferFrom(inChannel, 0, length); } else { final int BUFFER_SIZE = 8192; byte[] buffer = new byte[BUFFER_SIZE];