Function: archive-squashfs-summarize
archive-squashfs-summarize is a byte-compiled function defined in
arc-mode.el.gz.
Signature
(archive-squashfs-summarize &optional FILE)
Source Code
;; Defined in /usr/src/emacs/lisp/arc-mode.el.gz
;; -------------------------------------------------------------------------
;;; Section Squashfs archives.
(defun archive-squashfs-summarize (&optional file)
(unless file
(setq file buffer-file-name))
(let ((copy (file-local-copy file))
(files ())
to-delete)
;; Similar to 'archive-maybe-copy'.
(unless (or (and copy (null file))
(file-readable-p file))
(setq archive-local-name
(archive-unique-fname (or file copy (buffer-name))
archive-tmpdir)
file archive-local-name
to-delete t)
(save-restriction
(widen)
(let ((coding-system-for-write 'no-conversion))
(write-region (point-min) (point-max)
archive-local-name nil 'nomessage))))
(with-temp-buffer
(call-process "unsquashfs" nil t nil "-ll" (or file copy))
(when copy
(delete-file copy))
(goto-char (point-min))
(search-forward-regexp "[drwxl\\-]\\{10\\}")
(beginning-of-line)
(while (looking-at (concat
"^\\(.[rwx\\-]\\{9\\}\\) " ;Mode
"\\(.+\\)/\\(.+\\) " ;user/group
"\\(.+\\) " ;size
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\) " ;date
"\\([0-9]\\{2\\}:[0-9]\\{2\\}\\) " ;time
"\\(.+\\)\n")) ;Filename
(let* ((name (match-string 7))
(flags (match-string 1))
(uid (match-string 2))
(gid (match-string 3))
(size (string-to-number (match-string 4)))
(date (match-string 5))
(time (match-string 6))
(date-time)
(mode))
;; Only list directory and regular files
(when (or (eq (aref flags 0) ?d)
(eq (aref flags 0) ?-))
(when (equal name "squashfs-root")
(setf name "/"))
;; Remove 'squashfs-root/' from filenames.
(setq name (string-replace "squashfs-root/" "" name))
(setq date-time (concat date " " time))
(setq mode (logior
(cond
((eq (aref flags 0) ?d) #o40000)
(t 0))
;; Convert symbolic to octal representation.
(file-modes-symbolic-to-number
(concat
"u=" (string-replace "-" "" (substring flags 1 4))
",g=" (string-replace "-" "" (substring flags 4 7))
",o=" (string-replace "-" ""
(substring flags 7 10))))))
(push (archive--file-desc name name mode size
date-time :uid uid :gid gid)
files)))
(goto-char (match-end 0))))
(if to-delete
(archive-delete-local archive-local-name))
(archive--summarize-descs (nreverse files))))