comparison lisp/arc-mode.el @ 90813:e6fdae9180d4

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 698-710) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 216) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-196
author Miles Bader <miles@gnu.org>
date Tue, 24 Apr 2007 21:56:25 +0000
parents 95d0cdf160ea 1b3aff56da73
children f55f9811f5d7
comparison
equal deleted inserted replaced
90812:6137cc8ddf90 90813:e6fdae9180d4
721 ((looking-at "....................[\334]\247\304\375") 'zoo) 721 ((looking-at "....................[\334]\247\304\375") 'zoo)
722 ((and (looking-at "\C-z") ; signature too simple, IMHO 722 ((and (looking-at "\C-z") ; signature too simple, IMHO
723 (string-match "\\.[aA][rR][cC]$" 723 (string-match "\\.[aA][rR][cC]$"
724 (or buffer-file-name (buffer-name)))) 724 (or buffer-file-name (buffer-name))))
725 'arc) 725 'arc)
726 ;; This pattern modelled on the BSD/GNU+Linux `file' command.
727 ;; Have seen capital "LHA's", and file has lower case "LHa's" too.
728 ;; Note this regexp is also in archive-exe-p.
729 ((looking-at "MZ\\(.\\|\n\\)\\{34\\}LH[aA]'s SFX ") 'lzh-exe)
726 (t (error "Buffer format not recognized"))))) 730 (t (error "Buffer format not recognized")))))
727 ;; ------------------------------------------------------------------------- 731 ;; -------------------------------------------------------------------------
728 (defun archive-summarize (&optional shut-up) 732 (defun archive-summarize (&optional shut-up)
729 "Parse the contents of the archive file in the current buffer. 733 "Parse the contents of the archive file in the current buffer.
730 Place a dired-like listing on the front; 734 Place a dired-like listing on the front;
1419 (delete-char 13) 1423 (delete-char 13)
1420 (insert-unibyte name))))) 1424 (insert-unibyte name)))))
1421 ;; ------------------------------------------------------------------------- 1425 ;; -------------------------------------------------------------------------
1422 ;; Section: Lzh Archives 1426 ;; Section: Lzh Archives
1423 1427
1424 (defun archive-lzh-summarize () 1428 (defun archive-lzh-summarize (&optional start)
1425 (let ((p 1) 1429 (let ((p (or start 1)) ;; 1 for .lzh, something further on for .exe
1426 (totalsize 0) 1430 (totalsize 0)
1427 (maxlen 8) 1431 (maxlen 8)
1428 files 1432 files
1429 visual) 1433 visual)
1430 (while (progn (goto-char p) ;beginning of a base header. 1434 (while (progn (goto-char p) ;beginning of a base header.
1436 (ucsize (archive-l-e (+ p 11) 4 'float)) ;size of an uncompressed file. 1440 (ucsize (archive-l-e (+ p 11) 4 'float)) ;size of an uncompressed file.
1437 (time1 (archive-l-e (+ p 15) 2)) ;date/time (MSDOS format in level 0, 1 headers 1441 (time1 (archive-l-e (+ p 15) 2)) ;date/time (MSDOS format in level 0, 1 headers
1438 (time2 (archive-l-e (+ p 17) 2)) ;and UNIX format in level 2 header.) 1442 (time2 (archive-l-e (+ p 17) 2)) ;and UNIX format in level 2 header.)
1439 (hdrlvl (byte-after (+ p 20))) ;header level 1443 (hdrlvl (byte-after (+ p 20))) ;header level
1440 thsize ;total header size (base + extensions) 1444 thsize ;total header size (base + extensions)
1441 fnlen efnname fiddle ifnname width p2 1445 fnlen efnname osid fiddle ifnname width p2
1442 neh ;beginning of next extension header (level 1 and 2) 1446 neh ;beginning of next extension header (level 1 and 2)
1443 mode modestr uid gid text dir prname 1447 mode modestr uid gid text dir prname
1444 gname uname modtime moddate) 1448 gname uname modtime moddate)
1445 (if (= hdrlvl 3) (error "can't handle lzh level 3 header type")) 1449 (if (= hdrlvl 3) (error "can't handle lzh level 3 header type"))
1446 (when (or (= hdrlvl 0) (= hdrlvl 1)) 1450 (when (or (= hdrlvl 0) (= hdrlvl 1))
1494 (setq etype (byte-after (+ neh 2)))) 1498 (setq etype (byte-after (+ neh 2))))
1495 ;;get total header size for level 1 and 2 headers 1499 ;;get total header size for level 1 and 2 headers
1496 (setq thsize (- neh p)))) 1500 (setq thsize (- neh p))))
1497 (if (= hdrlvl 0) ;total header size 1501 (if (= hdrlvl 0) ;total header size
1498 (setq thsize hsize)) 1502 (setq thsize hsize))
1499 (setq fiddle (if efnname (string= efnname (upcase efnname)))) 1503 ;; OS ID field not present in level 0 header, use code 0 "generic"
1504 ;; in that case as per lha program header.c get_header()
1505 (setq osid (cond ((= hdrlvl 0) 0)
1506 ((= hdrlvl 1) (char-after (+ p 22 fnlen 2)))
1507 ((= hdrlvl 2) (char-after (+ p 23)))))
1508 ;; Filename fiddling must follow the lha program, otherwise the name
1509 ;; passed to "lha pq" etc won't match (which for an extract silently
1510 ;; results in no output). As of version 1.14i it goes from the OS ID,
1511 ;; - For 'M' MSDOS: msdos_to_unix_filename() downcases always, and
1512 ;; converts "\" to "/".
1513 ;; - For 0 generic: generic_to_unix_filename() downcases if there's
1514 ;; no lower case already present, and converts "\" to "/".
1515 ;; - For 'm' MacOS: macos_to_unix_filename() changes "/" to ":" and
1516 ;; ":" to "/"
1517 (setq fiddle (cond ((= ?M osid) t)
1518 ((= 0 osid) (string= efnname (upcase efnname)))))
1500 (setq ifnname (if fiddle (downcase efnname) efnname)) 1519 (setq ifnname (if fiddle (downcase efnname) efnname))
1501 (setq prname (if dir (concat dir ifnname) ifnname)) 1520 (setq prname (if dir (concat dir ifnname) ifnname))
1502 (setq width (if prname (string-width prname) 0)) 1521 (setq width (if prname (string-width prname) 0))
1503 (setq modestr (if mode (archive-int-to-mode mode) "??????????")) 1522 (setq modestr (if mode (archive-int-to-mode mode) "??????????"))
1504 (setq moddate (if (= hdrlvl 2) 1523 (setq moddate (if (= hdrlvl 2)
1623 (defun archive-lzh-chmod-entry (newmode files) 1642 (defun archive-lzh-chmod-entry (newmode files)
1624 (archive-lzh-ogm 1643 (archive-lzh-ogm
1625 ;; This should work even though newmode will be dynamically accessed. 1644 ;; This should work even though newmode will be dynamically accessed.
1626 (lambda (old) (archive-calc-mode old newmode t)) 1645 (lambda (old) (archive-calc-mode old newmode t))
1627 files "a unix-style mode" 8)) 1646 files "a unix-style mode" 8))
1647
1648 ;; -------------------------------------------------------------------------
1649 ;; Section: Lzh Self-Extracting .exe Archives
1650 ;;
1651 ;; No support for modifying these files. It looks like the lha for unix
1652 ;; program (as of version 1.14i) can't create or retain the DOS exe part.
1653 ;; If you do an "lha a" on a .exe for instance it renames and writes to a
1654 ;; plain .lzh.
1655
1656 (defun archive-lzh-exe-summarize ()
1657 "Summarize the contents of an LZH self-extracting exe, for `archive-mode'."
1658
1659 ;; Skip the initial executable code part and apply archive-lzh-summarize
1660 ;; to the archive part proper. The "-lh5-" etc regexp here for the start
1661 ;; is the same as in archive-find-type.
1662 ;;
1663 ;; The lha program (version 1.14i) does this in skip_msdos_sfx1_code() by
1664 ;; a similar scan. It looks for "..-l..-" plus for level 0 or 1 a test of
1665 ;; the header checksum, or level 2 a test of the "attribute" and size.
1666 ;;
1667 (re-search-forward "..-l[hz][0-9ds]-" nil)
1668 (archive-lzh-summarize (match-beginning 0)))
1669
1670 ;; `archive-lzh-extract' runs "lha pq", and that works for .exe as well as
1671 ;; .lzh files
1672 (defalias 'archive-lzh-exe-extract 'archive-lzh-extract
1673 "Extract a member from an LZH self-extracting exe, for `archive-mode'.")
1674
1628 ;; ------------------------------------------------------------------------- 1675 ;; -------------------------------------------------------------------------
1629 ;; Section: Zip Archives 1676 ;; Section: Zip Archives
1630 1677
1631 (defun archive-zip-summarize () 1678 (defun archive-zip-summarize ()
1632 (goto-char (- (point-max) (- 22 18))) 1679 (goto-char (- (point-max) (- 22 18)))