def unarchive
      unless in_zip?
        zips, gzs = selected_items.partition(&:zip?).tap {|z, others| break [z, *others.partition(&:gz?)]}
        zips.each do |item|
          FileUtils.mkdir_p current_dir.join(item.basename)
          Zip::File.open(item) do |zip|
            zip.each do |entry|
              FileUtils.mkdir_p File.join(item.basename, File.dirname(entry.to_s))
              zip.extract(entry, File.join(item.basename, entry.to_s)) { true }
            end
          end
        end
        gzs.each do |item|
          Zlib::GzipReader.open(item) do |gz|
            Gem::Package::TarReader.new(gz) do |tar|
              dest_dir = current_dir.join (gz.orig_name || item.basename).sub(/\.tar$/, '')
              tar.each do |entry|
                dest = nil
                if entry.full_name == '././@LongLink'
                  dest = File.join dest_dir, entry.read.strip
                  next
                end
                dest ||= File.join dest_dir, entry.full_name
                if entry.directory?
                  FileUtils.mkdir_p dest, :mode => entry.header.mode
                elsif entry.file?
                  FileUtils.mkdir_p dest_dir
                  File.open(dest, 'wb') {|f| f.print entry.read}
                  FileUtils.chmod entry.header.mode, dest
                elsif entry.header.typeflag == '2'  # symlink
                  File.symlink entry.header.linkname, dest
                end
                unless Dir.exist? dest_dir
                  FileUtils.mkdir_p dest_dir
                  File.open(File.join(dest_dir, gz.orig_name || item.basename), 'wb') {|f| f.print gz.read}
                end
              end
            end
          end
        end
      else
        Zip::File.open(current_zip) do |zip|
          zip.select {|e| selected_items.map(&:name).include? e.to_s}.each do |entry|
            FileUtils.mkdir_p File.join(current_zip.dir, current_zip.basename, File.dirname(entry.to_s))
            zip.extract(entry, File.join(current_zip.dir, current_zip.basename, entry.to_s)) { true }
          end
        end
      end
      ls
    end
def unarchive
      unless in_zip?
        zips, gzs = selected_items.partition(&:zip?).tap {|z, others| break [z, *others.partition(&:gz?)]}
        zips.each do |item|
          FileUtils.mkdir_p current_dir.join(item.basename)
          Zip::File.open(item) do |zip|
            zip.each do |entry|
              FileUtils.mkdir_p File.join(item.basename, File.dirname(entry.to_s))
              zip.extract(entry, File.join(item.basename, entry.to_s)) { true }
            end
          end
        end
        gzs.each do |item|
          Zlib::GzipReader.open(item) do |gz|
            Gem::Package::TarReader.new(gz) do |tar|
              dest_dir = current_dir.join (gz.orig_name || item.basename).sub(/\.tar$/, '')
              tar.each do |entry|
                dest = nil
                if entry.full_name == '././@LongLink'
                  dest = File.join dest_dir, entry.read.strip
                  next
                end
                dest ||= File.join dest_dir, entry.full_name
                if entry.directory?
                  FileUtils.mkdir_p dest, :mode => entry.header.mode
                elsif entry.file?
                  FileUtils.mkdir_p dest_dir
                  File.open(dest, 'wb') {|f| f.print entry.read}
                  FileUtils.chmod entry.header.mode, dest
                elsif entry.header.typeflag == '2'  # symlink
                  File.symlink entry.header.linkname, dest
                end
                unless Dir.exist? dest_dir
                  FileUtils.mkdir_p dest_dir
                  File.open(File.join(dest_dir, gz.orig_name || item.basename), 'wb') {|f| f.print gz.read}
                end
              end
            end
          end
        end
      else
        Zip::File.open(current_zip) do |zip|
          zip.select {|e| selected_items.map(&:name).include? e.to_s}.each do |entry|
            FileUtils.mkdir_p File.join(current_zip.dir, current_zip.basename, File.dirname(entry.to_s))
            zip.extract(entry, File.join(current_zip.dir, current_zip.basename, entry.to_s)) { true }
          end
        end
      end
      ls
    end
Unarchive .zip and .tar.gz files within selected files and directories into current_directory.