Function: cider-jar--archive-zip-summarize

cider-jar--archive-zip-summarize is a byte-compiled function defined in cider-jar.el.

Signature

(cider-jar--archive-zip-summarize)

Documentation

Forked version of archive-zip-summarize.

Only read the information we need, and be version independent.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-jar.el
(defun cider-jar--archive-zip-summarize ()
  "Forked version of `archive-zip-summarize'.
Only read the information we need, and be version independent."
  (goto-char (- (point-max) (- 22 18)))
  (search-backward-regexp "[P]K\005\006")
  (let ((p (archive-l-e (+ (point) 16) 4))
        files)
    (when (or (= p #xffffffff) (= p -1))
      ;; If the offset of end-of-central-directory is 0xFFFFFFFF, this
      ;; is a Zip64 extended ZIP file format, and we need to glean the
      ;; info from Zip64 records instead.
      ;;
      ;; First, find the Zip64 end-of-central-directory locator.
      (search-backward "PK\006\007")
      (setq p (+ (point-min)
                 (archive-l-e (+ (point) 8) 8)))
      (goto-char p)
      ;; We should be at Zip64 end-of-central-directory record now.
      (or (string= "PK\006\006" (buffer-substring p (+ p 4)))
          (error "Unrecognized ZIP file format"))
      ;; Offset to central directory:
      (setq p (archive-l-e (+ p 48) 8)))
    (setq p (+ p (point-min)))
    (while (string= "PK\001\002" (buffer-substring p (+ p 4)))
      (let* ((fnlen   (archive-l-e (+ p 28) 2))
             (exlen   (archive-l-e (+ p 30) 2))
             (fclen   (archive-l-e (+ p 32) 2))
             (efnname (let ((str (buffer-substring (+ p 46) (+ p 46 fnlen))))
                        (decode-coding-string
                         str archive-file-name-coding-system))))
        (setq files (cons efnname files)
              p (+ p 46 fnlen exlen fclen))))
    files))