@@ -272,7 +272,7 @@ private void copyFile(Filesystem srcFs, LocalFilesystemURL srcURL, File destFile
272272 }
273273
274274 CordovaResourceApi .OpenForReadResult offr = resourceApi .openForRead (srcFs .toNativeUri (srcURL ));
275- copyResource (offr , new FileOutputStream (destFile ));
275+ resourceApi . copyResource (offr , new FileOutputStream (destFile ));
276276
277277 if (move ) {
278278 srcFs .removeFileAtLocalURL (srcURL );
@@ -470,44 +470,4 @@ public boolean canRemoveFileAtLocalURL(LocalFilesystemURL inputURL) {
470470 File file = new File (path );
471471 return file .exists ();
472472 }
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 [email protected] 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- }
513473}
0 commit comments