Mercurial > emacs
comparison lisp/arc-mode.el @ 77330:1b3aff56da73
(archive-find-type): lzh-exe for lzh self-extracting exe.
(archive-lzh-summarize): Add optional start arg for where to start
looking at the archive.
(archive-lzh-exe-summarize, archive-lzh-exe-extract): New functions.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Thu, 19 Apr 2007 23:53:02 +0000 |
parents | d966323ac214 |
children | 9355f9b7bbff e6fdae9180d4 |
comparison
equal
deleted
inserted
replaced
77329:40604938395a | 77330:1b3aff56da73 |
---|---|
698 ((looking-at "....................[\334]\247\304\375") 'zoo) | 698 ((looking-at "....................[\334]\247\304\375") 'zoo) |
699 ((and (looking-at "\C-z") ; signature too simple, IMHO | 699 ((and (looking-at "\C-z") ; signature too simple, IMHO |
700 (string-match "\\.[aA][rR][cC]$" | 700 (string-match "\\.[aA][rR][cC]$" |
701 (or buffer-file-name (buffer-name)))) | 701 (or buffer-file-name (buffer-name)))) |
702 'arc) | 702 'arc) |
703 ;; This pattern modelled on the BSD/GNU+Linux `file' command. | |
704 ;; Have seen capital "LHA's", and file has lower case "LHa's" too. | |
705 ;; Note this regexp is also in archive-exe-p. | |
706 ((looking-at "MZ\\(.\\|\n\\)\\{34\\}LH[aA]'s SFX ") 'lzh-exe) | |
703 (t (error "Buffer format not recognized"))))) | 707 (t (error "Buffer format not recognized"))))) |
704 ;; ------------------------------------------------------------------------- | 708 ;; ------------------------------------------------------------------------- |
705 (defun archive-summarize (&optional shut-up) | 709 (defun archive-summarize (&optional shut-up) |
706 "Parse the contents of the archive file in the current buffer. | 710 "Parse the contents of the archive file in the current buffer. |
707 Place a dired-like listing on the front; | 711 Place a dired-like listing on the front; |
1396 (delete-char 13) | 1400 (delete-char 13) |
1397 (insert name))))) | 1401 (insert name))))) |
1398 ;; ------------------------------------------------------------------------- | 1402 ;; ------------------------------------------------------------------------- |
1399 ;; Section: Lzh Archives | 1403 ;; Section: Lzh Archives |
1400 | 1404 |
1401 (defun archive-lzh-summarize () | 1405 (defun archive-lzh-summarize (&optional start) |
1402 (let ((p 1) | 1406 (let ((p (or start 1)) ;; 1 for .lzh, something further on for .exe |
1403 (totalsize 0) | 1407 (totalsize 0) |
1404 (maxlen 8) | 1408 (maxlen 8) |
1405 files | 1409 files |
1406 visual) | 1410 visual) |
1407 (while (progn (goto-char p) ;beginning of a base header. | 1411 (while (progn (goto-char p) ;beginning of a base header. |
1619 (defun archive-lzh-chmod-entry (newmode files) | 1623 (defun archive-lzh-chmod-entry (newmode files) |
1620 (archive-lzh-ogm | 1624 (archive-lzh-ogm |
1621 ;; This should work even though newmode will be dynamically accessed. | 1625 ;; This should work even though newmode will be dynamically accessed. |
1622 (lambda (old) (archive-calc-mode old newmode t)) | 1626 (lambda (old) (archive-calc-mode old newmode t)) |
1623 files "a unix-style mode" 8)) | 1627 files "a unix-style mode" 8)) |
1628 | |
1629 ;; ------------------------------------------------------------------------- | |
1630 ;; Section: Lzh Self-Extracting .exe Archives | |
1631 ;; | |
1632 ;; No support for modifying these files. It looks like the lha for unix | |
1633 ;; program (as of version 1.14i) can't create or retain the DOS exe part. | |
1634 ;; If you do an "lha a" on a .exe for instance it renames and writes to a | |
1635 ;; plain .lzh. | |
1636 | |
1637 (defun archive-lzh-exe-summarize () | |
1638 "Summarize the contents of an LZH self-extracting exe, for `archive-mode'." | |
1639 | |
1640 ;; Skip the initial executable code part and apply archive-lzh-summarize | |
1641 ;; to the archive part proper. The "-lh5-" etc regexp here for the start | |
1642 ;; is the same as in archive-find-type. | |
1643 ;; | |
1644 ;; The lha program (version 1.14i) does this in skip_msdos_sfx1_code() by | |
1645 ;; a similar scan. It looks for "..-l..-" plus for level 0 or 1 a test of | |
1646 ;; the header checksum, or level 2 a test of the "attribute" and size. | |
1647 ;; | |
1648 (re-search-forward "..-l[hz][0-9ds]-" nil) | |
1649 (archive-lzh-summarize (match-beginning 0))) | |
1650 | |
1651 ;; `archive-lzh-extract' runs "lha pq", and that works for .exe as well as | |
1652 ;; .lzh files | |
1653 (defalias 'archive-lzh-exe-extract 'archive-lzh-extract | |
1654 "Extract a member from an LZH self-extracting exe, for `archive-mode'.") | |
1655 | |
1624 ;; ------------------------------------------------------------------------- | 1656 ;; ------------------------------------------------------------------------- |
1625 ;; Section: Zip Archives | 1657 ;; Section: Zip Archives |
1626 | 1658 |
1627 (defun archive-zip-summarize () | 1659 (defun archive-zip-summarize () |
1628 (goto-char (- (point-max) (- 22 18))) | 1660 (goto-char (- (point-max) (- 22 18))) |