@@ -272,7 +272,7 @@ private void copyFile(Filesystem srcFs, LocalFilesystemURL srcURL, File destFile
272
272
}
273
273
274
274
CordovaResourceApi .OpenForReadResult offr = resourceApi .openForRead (srcFs .toNativeUri (srcURL ));
275
- copyResource (offr , new FileOutputStream (destFile ));
275
+ resourceApi . copyResource (offr , new FileOutputStream (destFile ));
276
276
277
277
if (move ) {
278
278
srcFs .removeFileAtLocalURL (srcURL );
@@ -470,44 +470,4 @@ public boolean canRemoveFileAtLocalURL(LocalFilesystemURL inputURL) {
470
470
File file = new File (path );
471
471
return file .exists ();
472
472
}
473
-
474
- // This is a copy & paste from CordovaResource API that is required since CordovaResourceApi
475
- // has a bug pre-4.0.0.
476
- // TODO: Once cordova-android@4.0.0 is released, delete this copy and make the plugin depend on
477
- // 4.0.0 with an engine tag.
478
- private static void copyResource (CordovaResourceApi .OpenForReadResult input , OutputStream outputStream ) throws IOException {
479
- try {
480
- InputStream inputStream = input .inputStream ;
481
- if (inputStream instanceof FileInputStream && outputStream instanceof FileOutputStream ) {
482
- FileChannel inChannel = ((FileInputStream )input .inputStream ).getChannel ();
483
- FileChannel outChannel = ((FileOutputStream )outputStream ).getChannel ();
484
- long offset = 0 ;
485
- long length = input .length ;
486
- if (input .assetFd != null ) {
487
- offset = input .assetFd .getStartOffset ();
488
- }
489
- // transferFrom()'s 2nd arg is a relative position. Need to set the absolute
490
- // position first.
491
- inChannel .position (offset );
492
- outChannel .transferFrom (inChannel , 0 , length );
493
- } else {
494
- final int BUFFER_SIZE = 8192 ;
495
- byte [] buffer = new byte [BUFFER_SIZE ];
496
-
497
- for (;;) {
498
- int bytesRead = inputStream .read (buffer , 0 , BUFFER_SIZE );
499
-
500
- if (bytesRead <= 0 ) {
501
- break ;
502
- }
503
- outputStream .write (buffer , 0 , bytesRead );
504
- }
505
- }
506
- } finally {
507
- input .inputStream .close ();
508
- if (outputStream != null ) {
509
- outputStream .close ();
510
- }
511
- }
512
- }
513
473
}
0 commit comments