Beispiel #1
0
        public void run() throws IOException {
          // Update controllers.
          // This may invalidate the file system object, so it must be
          // done first in case srcController and dstController are the
          // same!
          class SrcControllerUpdater implements IORunnable {
            public void run() throws IOException {
              srcController.autoUmount(srcEntryName);
              srcController.readLock().lock(); // downgrade to read lock upon return
            }
          } // class SrcControllerUpdater

          final ArchiveEntry srcEntry, dstEntry;
          final Delta delta;
          srcController.runWriteLocked(new SrcControllerUpdater());
          try {
            dstController.autoUmount(dstEntryName);

            // Get source archive entry.
            final ArchiveFileSystem srcFileSystem = srcController.autoMount(false);
            srcEntry = srcFileSystem.get(srcEntryName);

            // Get destination archive entry.
            final boolean lenient = File.isLenient();
            final ArchiveFileSystem dstFileSystem = dstController.autoMount(lenient);
            delta = dstFileSystem.link(dstEntryName, lenient, preserve ? srcEntry : null);
            dstEntry = delta.getEntry();

            // Create input stream.
            in = srcController.createInputStream(srcEntry, dstEntry);
          } finally {
            srcController.readLock().unlock();
          }

          try {
            // Create output stream.
            out = dstController.createOutputStream(dstEntry, srcEntry);

            try {
              // Now link the destination entry into the file system.
              delta.commit();
            } catch (IOException ex) {
              out.close();
              throw ex;
            }
          } catch (IOException ex) {
            try {
              in.close();
            } catch (IOException inFailure) {
              throw new InputIOException(inFailure);
            }
            throw ex;
          }
        }
Beispiel #2
0
        public void run() throws IOException {
          // Update controller.
          // This may invalidate the file system object, so it must be
          // done first in case srcController and dstController are the
          // same!
          dstController.autoUmount(dstEntryName);

          final boolean lenient = File.isLenient();

          // Get source archive entry.
          final ArchiveEntry srcEntry = new RfsEntry(src);

          // Get destination archive entry.
          final ArchiveFileSystem dstFileSystem = dstController.autoMount(lenient);
          final Delta delta = dstFileSystem.link(dstEntryName, lenient, preserve ? srcEntry : null);
          final ArchiveEntry dstEntry = delta.getEntry();

          // Create output stream.
          out = dstController.createOutputStream(dstEntry, srcEntry);

          // Now link the destination entry into the file system.
          delta.commit();
        }