diff options
| -rw-r--r-- | lisp/arc-mode.el | 122 |
1 files changed, 63 insertions, 59 deletions
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 4609123dec9..0a7816c2252 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el | |||
| @@ -497,8 +497,23 @@ Its value is an `archive--file-desc'.") | |||
| 497 | (cl-defstruct (archive--file-desc | 497 | (cl-defstruct (archive--file-desc |
| 498 | (:constructor nil) | 498 | (:constructor nil) |
| 499 | (:constructor archive--file-desc | 499 | (:constructor archive--file-desc |
| 500 | (ext-file-name int-file-name case-fiddled mode))) | 500 | ;; ext-file-name and int-file-name are usually `eq' |
| 501 | ext-file-name int-file-name case-fiddled mode) | 501 | ;; except when int-file-name is the downcased |
| 502 | ;; ext-file-name. | ||
| 503 | (ext-file-name int-file-name mode))) | ||
| 504 | ext-file-name int-file-name mode) | ||
| 505 | |||
| 506 | ;; Features in formats: | ||
| 507 | ;; | ||
| 508 | ;; ARC: size, date, time (date and time strings internally generated) | ||
| 509 | ;; LZH: size, date, time, mode, uid, gid (mode, date, time generated, ugid:int) | ||
| 510 | ;; ZIP: size, date, time, mode (mode, date, time generated) | ||
| 511 | ;; ZOO: size, date, time (date and time strings internally generated) | ||
| 512 | ;; AR : size, date, time, mode, user, group (internally generated) | ||
| 513 | ;; RAR: size, date, time, ratio (all as strings, using `lsar') | ||
| 514 | ;; 7Z : size, date, time (all as strings, using `7z' or `7za') | ||
| 515 | ;; | ||
| 516 | ;; LZH has alternate display (with UID/GID i.s.o MODE/DATE/TIME | ||
| 502 | 517 | ||
| 503 | (defvar archive-files nil | 518 | (defvar archive-files nil |
| 504 | "Vector of `archive--file-desc' objects.") | 519 | "Vector of `archive--file-desc' objects.") |
| @@ -537,23 +552,25 @@ in which case a second argument, length LEN, should be supplied." | |||
| 537 | (defun archive-int-to-mode (mode) | 552 | (defun archive-int-to-mode (mode) |
| 538 | "Turn an integer like 0700 (i.e., 448) into a mode string like -rwx------." | 553 | "Turn an integer like 0700 (i.e., 448) into a mode string like -rwx------." |
| 539 | ;; FIXME: merge with tar-grind-file-mode. | 554 | ;; FIXME: merge with tar-grind-file-mode. |
| 540 | (string | 555 | (if (null mode) |
| 541 | (if (zerop (logand 8192 mode)) | 556 | "??????????" |
| 542 | (if (zerop (logand 16384 mode)) ?- ?d) | 557 | (string |
| 543 | ?c) ; completeness | 558 | (if (zerop (logand 8192 mode)) |
| 544 | (if (zerop (logand 256 mode)) ?- ?r) | 559 | (if (zerop (logand 16384 mode)) ?- ?d) |
| 545 | (if (zerop (logand 128 mode)) ?- ?w) | 560 | ?c) ; completeness |
| 546 | (if (zerop (logand 64 mode)) | 561 | (if (zerop (logand 256 mode)) ?- ?r) |
| 547 | (if (zerop (logand 2048 mode)) ?- ?S) | 562 | (if (zerop (logand 128 mode)) ?- ?w) |
| 548 | (if (zerop (logand 2048 mode)) ?x ?s)) | 563 | (if (zerop (logand 64 mode)) |
| 549 | (if (zerop (logand 32 mode)) ?- ?r) | 564 | (if (zerop (logand 2048 mode)) ?- ?S) |
| 550 | (if (zerop (logand 16 mode)) ?- ?w) | 565 | (if (zerop (logand 2048 mode)) ?x ?s)) |
| 551 | (if (zerop (logand 8 mode)) | 566 | (if (zerop (logand 32 mode)) ?- ?r) |
| 552 | (if (zerop (logand 1024 mode)) ?- ?S) | 567 | (if (zerop (logand 16 mode)) ?- ?w) |
| 553 | (if (zerop (logand 1024 mode)) ?x ?s)) | 568 | (if (zerop (logand 8 mode)) |
| 554 | (if (zerop (logand 4 mode)) ?- ?r) | 569 | (if (zerop (logand 1024 mode)) ?- ?S) |
| 555 | (if (zerop (logand 2 mode)) ?- ?w) | 570 | (if (zerop (logand 1024 mode)) ?x ?s)) |
| 556 | (if (zerop (logand 1 mode)) ?- ?x))) | 571 | (if (zerop (logand 4 mode)) ?- ?r) |
| 572 | (if (zerop (logand 2 mode)) ?- ?w) | ||
| 573 | (if (zerop (logand 1 mode)) ?- ?x)))) | ||
| 557 | 574 | ||
| 558 | (defun archive-calc-mode (oldmode newmode) | 575 | (defun archive-calc-mode (oldmode newmode) |
| 559 | "From the integer OLDMODE and the string NEWMODE calculate a new file mode. | 576 | "From the integer OLDMODE and the string NEWMODE calculate a new file mode. |
| @@ -1443,8 +1460,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1443 | (:include archive--file-desc) | 1460 | (:include archive--file-desc) |
| 1444 | (:constructor nil) | 1461 | (:constructor nil) |
| 1445 | (:constructor archive-arc--file-desc | 1462 | (:constructor archive-arc--file-desc |
| 1446 | (ext-file-name int-file-name case-fiddled mode | 1463 | (ext-file-name int-file-name mode pos))) |
| 1447 | pos))) | ||
| 1448 | pos) | 1464 | pos) |
| 1449 | 1465 | ||
| 1450 | (defun archive-arc-summarize () | 1466 | (defun archive-arc-summarize () |
| @@ -1479,7 +1495,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1479 | (length text)) | 1495 | (length text)) |
| 1480 | visual) | 1496 | visual) |
| 1481 | files (cons (archive-arc--file-desc | 1497 | files (cons (archive-arc--file-desc |
| 1482 | efnname ifnname fiddle nil (1- p)) | 1498 | efnname ifnname nil (1- p)) |
| 1483 | files) | 1499 | files) |
| 1484 | p (+ p 29 csize)))) | 1500 | p (+ p 29 csize)))) |
| 1485 | (goto-char (point-min)) | 1501 | (goto-char (point-min)) |
| @@ -1502,8 +1518,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1502 | (error "File names in arc files must not contain a directory component")) | 1518 | (error "File names in arc files must not contain a directory component")) |
| 1503 | (if (> (length newname) 12) | 1519 | (if (> (length newname) 12) |
| 1504 | (error "File names in arc files are limited to 12 characters")) | 1520 | (error "File names in arc files are limited to 12 characters")) |
| 1505 | (let ((name (concat newname (substring "\0\0\0\0\0\0\0\0\0\0\0\0\0" | 1521 | (let ((name (concat newname (make-string (- 13 (length newname)) ?\0))) |
| 1506 | (length newname)))) | ||
| 1507 | (inhibit-read-only t)) | 1522 | (inhibit-read-only t)) |
| 1508 | (save-restriction | 1523 | (save-restriction |
| 1509 | (save-excursion | 1524 | (save-excursion |
| @@ -1519,8 +1534,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1519 | (:include archive--file-desc) | 1534 | (:include archive--file-desc) |
| 1520 | (:constructor nil) | 1535 | (:constructor nil) |
| 1521 | (:constructor archive-lzh--file-desc | 1536 | (:constructor archive-lzh--file-desc |
| 1522 | (ext-file-name int-file-name case-fiddled mode | 1537 | (ext-file-name int-file-name mode pos))) |
| 1523 | pos))) | ||
| 1524 | pos) | 1538 | pos) |
| 1525 | 1539 | ||
| 1526 | (defun archive-lzh-summarize (&optional start) | 1540 | (defun archive-lzh-summarize (&optional start) |
| @@ -1616,7 +1630,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1616 | (setq ifnname (if fiddle (downcase efnname) efnname)) | 1630 | (setq ifnname (if fiddle (downcase efnname) efnname)) |
| 1617 | (setq prname (if dir (concat dir ifnname) ifnname)) | 1631 | (setq prname (if dir (concat dir ifnname) ifnname)) |
| 1618 | (setq width (if prname (string-width prname) 0)) | 1632 | (setq width (if prname (string-width prname) 0)) |
| 1619 | (setq modestr (if mode (archive-int-to-mode mode) "??????????")) | 1633 | (setq modestr (archive-int-to-mode mode)) |
| 1620 | (setq moddate (if (= hdrlvl 2) | 1634 | (setq moddate (if (= hdrlvl 2) |
| 1621 | (archive-unixdate time1 time2) ;level 2 header in UNIX format | 1635 | (archive-unixdate time1 time2) ;level 2 header in UNIX format |
| 1622 | (archive-dosdate time2))) ;level 0 and 1 header in DOS format | 1636 | (archive-dosdate time2))) ;level 0 and 1 header in DOS format |
| @@ -1643,7 +1657,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1643 | (length text)) | 1657 | (length text)) |
| 1644 | visual) | 1658 | visual) |
| 1645 | files (cons (archive-lzh--file-desc | 1659 | files (cons (archive-lzh--file-desc |
| 1646 | prname ifnname fiddle mode (1- p)) | 1660 | prname ifnname mode (1- p)) |
| 1647 | files)) | 1661 | files)) |
| 1648 | (cond ((= hdrlvl 1) | 1662 | (cond ((= hdrlvl 1) |
| 1649 | (setq p (+ p hsize 2 csize))) | 1663 | (setq p (+ p hsize 2 csize))) |
| @@ -1774,9 +1788,8 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1774 | (:include archive--file-desc) | 1788 | (:include archive--file-desc) |
| 1775 | (:constructor nil) | 1789 | (:constructor nil) |
| 1776 | (:constructor archive-zip--file-desc | 1790 | (:constructor archive-zip--file-desc |
| 1777 | (ext-file-name int-file-name case-fiddled mode | 1791 | (ext-file-name int-file-name mode pos))) |
| 1778 | pos+len))) | 1792 | pos) |
| 1779 | pos+len) | ||
| 1780 | 1793 | ||
| 1781 | (defun archive-zip-summarize () | 1794 | (defun archive-zip-summarize () |
| 1782 | (goto-char (- (point-max) (- 22 18))) | 1795 | (goto-char (- (point-max) (- 22 18))) |
| @@ -1811,7 +1824,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1811 | (fnlen (archive-l-e (+ p 28) 2)) | 1824 | (fnlen (archive-l-e (+ p 28) 2)) |
| 1812 | (exlen (archive-l-e (+ p 30) 2)) | 1825 | (exlen (archive-l-e (+ p 30) 2)) |
| 1813 | (fclen (archive-l-e (+ p 32) 2)) | 1826 | (fclen (archive-l-e (+ p 32) 2)) |
| 1814 | (lheader (archive-l-e (+ p 42) 4)) | 1827 | ;; (lheader (archive-l-e (+ p 42) 4)) |
| 1815 | (efnname (let ((str (buffer-substring (+ p 46) (+ p 46 fnlen)))) | 1828 | (efnname (let ((str (buffer-substring (+ p 46) (+ p 46 fnlen)))) |
| 1816 | (decode-coding-string | 1829 | (decode-coding-string |
| 1817 | str archive-file-name-coding-system))) | 1830 | str archive-file-name-coding-system))) |
| @@ -1826,9 +1839,9 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1826 | (logand 1 (get-byte (+ p 38)))) | 1839 | (logand 1 (get-byte (+ p 38)))) |
| 1827 | ?\222 0))) | 1840 | ?\222 0))) |
| 1828 | (t nil))) | 1841 | (t nil))) |
| 1829 | (modestr (if mode (archive-int-to-mode mode) "??????????")) | 1842 | (modestr (archive-int-to-mode mode)) |
| 1830 | (fiddle (and archive-zip-case-fiddle | 1843 | (fiddle (and archive-zip-case-fiddle |
| 1831 | (not (not (memq creator '(0 2 4 5 9)))) | 1844 | (memq creator '(0 2 4 5 9)) |
| 1832 | (string= (upcase efnname) efnname))) | 1845 | (string= (upcase efnname) efnname))) |
| 1833 | (ifnname (if fiddle (downcase efnname) efnname)) | 1846 | (ifnname (if fiddle (downcase efnname) efnname)) |
| 1834 | (width (string-width ifnname)) | 1847 | (width (string-width ifnname)) |
| @@ -1847,8 +1860,8 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1847 | visual) | 1860 | visual) |
| 1848 | files (cons (if isdir | 1861 | files (cons (if isdir |
| 1849 | nil | 1862 | nil |
| 1850 | (archive-zip--file-desc efnname ifnname fiddle mode | 1863 | (archive-zip--file-desc efnname ifnname mode |
| 1851 | (list (1- p) lheader))) | 1864 | (1- p))) |
| 1852 | files) | 1865 | files) |
| 1853 | p (+ p 46 fnlen exlen fclen)))) | 1866 | p (+ p 46 fnlen exlen fclen)))) |
| 1854 | (goto-char (point-min)) | 1867 | (goto-char (point-min)) |
| @@ -1889,6 +1902,10 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1889 | name) | 1902 | name) |
| 1890 | archive-zip-extract)))) | 1903 | archive-zip-extract)))) |
| 1891 | 1904 | ||
| 1905 | (defun archive--file-desc-case-fiddled (fd) | ||
| 1906 | (not (eq (archive--file-desc-int-file-name fd) | ||
| 1907 | (archive--file-desc-ext-file-name fd)))) | ||
| 1908 | |||
| 1892 | (defun archive-zip-write-file-member (archive descr) | 1909 | (defun archive-zip-write-file-member (archive descr) |
| 1893 | (archive-*-write-file-member | 1910 | (archive-*-write-file-member |
| 1894 | archive | 1911 | archive |
| @@ -1902,7 +1919,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1902 | (widen) | 1919 | (widen) |
| 1903 | (dolist (fil files) | 1920 | (dolist (fil files) |
| 1904 | (let* ((p (+ archive-proper-file-start | 1921 | (let* ((p (+ archive-proper-file-start |
| 1905 | (car (archive-zip--file-desc-pos+len fil)))) | 1922 | (archive-zip--file-desc-pos fil))) |
| 1906 | (creator (get-byte (+ p 5))) | 1923 | (creator (get-byte (+ p 5))) |
| 1907 | (oldmode (archive--file-desc-mode fil)) | 1924 | (oldmode (archive--file-desc-mode fil)) |
| 1908 | (newval (archive-calc-mode oldmode newmode)) | 1925 | (newval (archive-calc-mode oldmode newmode)) |
| @@ -1922,14 +1939,6 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1922 | ;; ------------------------------------------------------------------------- | 1939 | ;; ------------------------------------------------------------------------- |
| 1923 | ;;; Section: Zoo Archives | 1940 | ;;; Section: Zoo Archives |
| 1924 | 1941 | ||
| 1925 | (cl-defstruct (archive-zoo--file-desc | ||
| 1926 | (:include archive--file-desc) | ||
| 1927 | (:constructor nil) | ||
| 1928 | (:constructor archive-zoo--file-desc | ||
| 1929 | (ext-file-name int-file-name case-fiddled mode | ||
| 1930 | pos))) | ||
| 1931 | pos) | ||
| 1932 | |||
| 1933 | (defun archive-zoo-summarize () | 1942 | (defun archive-zoo-summarize () |
| 1934 | (let ((p (1+ (archive-l-e 25 4))) | 1943 | (let ((p (1+ (archive-l-e 25 4))) |
| 1935 | (maxlen 8) | 1944 | (maxlen 8) |
| @@ -1977,9 +1986,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1977 | (length text)) | 1986 | (length text)) |
| 1978 | visual) | 1987 | visual) |
| 1979 | ;; FIXME: Keep size/date(/mode?) in the desc! | 1988 | ;; FIXME: Keep size/date(/mode?) in the desc! |
| 1980 | files (cons (archive-zoo--file-desc | 1989 | files (cons (archive--file-desc efnname ifnname nil) |
| 1981 | ;; FIXME: The `pos' field seems unused! | ||
| 1982 | efnname ifnname fiddle nil (1- p)) | ||
| 1983 | files) | 1990 | files) |
| 1984 | p next))) | 1991 | p next))) |
| 1985 | (goto-char (point-min)) | 1992 | (goto-char (point-min)) |
| @@ -2007,8 +2014,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 2007 | (:include archive--file-desc) | 2014 | (:include archive--file-desc) |
| 2008 | (:constructor nil) | 2015 | (:constructor nil) |
| 2009 | (:constructor archive-rar--file-desc | 2016 | (:constructor archive-rar--file-desc |
| 2010 | (ext-file-name int-file-name case-fiddled mode | 2017 | (ext-file-name int-file-name mode size ratio date time))) |
| 2011 | size ratio date time))) | ||
| 2012 | size ratio date time) | 2018 | size ratio date time) |
| 2013 | 2019 | ||
| 2014 | (defun archive-rar-summarize (&optional file) | 2020 | (defun archive-rar-summarize (&optional file) |
| @@ -2036,7 +2042,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 2036 | (size (match-string 1))) | 2042 | (size (match-string 1))) |
| 2037 | (if (> (length name) maxname) (setq maxname (length name))) | 2043 | (if (> (length name) maxname) (setq maxname (length name))) |
| 2038 | (if (> (length size) maxsize) (setq maxsize (length size))) | 2044 | (if (> (length size) maxsize) (setq maxsize (length size))) |
| 2039 | (push (archive-rar--file-desc name name nil nil | 2045 | (push (archive-rar--file-desc name name nil |
| 2040 | ;; Size, Ratio. | 2046 | ;; Size, Ratio. |
| 2041 | size (match-string 2) | 2047 | size (match-string 2) |
| 2042 | ;; Date, Time. | 2048 | ;; Date, Time. |
| @@ -2115,9 +2121,8 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 2115 | (:include archive--file-desc) | 2121 | (:include archive--file-desc) |
| 2116 | (:constructor nil) | 2122 | (:constructor nil) |
| 2117 | (:constructor archive-7z--file-desc | 2123 | (:constructor archive-7z--file-desc |
| 2118 | (ext-file-name int-file-name case-fiddled mode | 2124 | (ext-file-name int-file-name mode time size))) |
| 2119 | time user group size))) | 2125 | time size) |
| 2120 | time user group size) | ||
| 2121 | 2126 | ||
| 2122 | (defun archive-7z-summarize () | 2127 | (defun archive-7z-summarize () |
| 2123 | (let ((maxname 10) | 2128 | (let ((maxname 10) |
| @@ -2141,7 +2146,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 2141 | (match-string 1))))) | 2146 | (match-string 1))))) |
| 2142 | (if (> (length name) maxname) (setq maxname (length name))) | 2147 | (if (> (length name) maxname) (setq maxname (length name))) |
| 2143 | (if (> (length size) maxsize) (setq maxsize (length size))) | 2148 | (if (> (length size) maxsize) (setq maxsize (length size))) |
| 2144 | (push (archive-7z--file-desc name name nil nil time nil nil size) | 2149 | (push (archive-7z--file-desc name name nil time size) |
| 2145 | files)))) | 2150 | files)))) |
| 2146 | (setq files (nreverse files)) | 2151 | (setq files (nreverse files)) |
| 2147 | (goto-char (point-min)) | 2152 | (goto-char (point-min)) |
| @@ -2187,8 +2192,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 2187 | (:include archive--file-desc) | 2192 | (:include archive--file-desc) |
| 2188 | (:constructor nil) | 2193 | (:constructor nil) |
| 2189 | (:constructor archive-ar--file-desc | 2194 | (:constructor archive-ar--file-desc |
| 2190 | (ext-file-name int-file-name case-fiddled mode | 2195 | (ext-file-name int-file-name mode time user group size))) |
| 2191 | time user group size))) | ||
| 2192 | time user group size) | 2196 | time user group size) |
| 2193 | 2197 | ||
| 2194 | (autoload 'tar-grind-file-mode "tar-mode") | 2198 | (autoload 'tar-grind-file-mode "tar-mode") |
| @@ -2232,7 +2236,7 @@ NAME is expected to be the 16-bytes part of an ar record." | |||
| 2232 | (setq extname (archive-ar--name name)) | 2236 | (setq extname (archive-ar--name name)) |
| 2233 | (setq user (substring user 0 (string-match " +\\'" user))) | 2237 | (setq user (substring user 0 (string-match " +\\'" user))) |
| 2234 | (setq group (substring group 0 (string-match " +\\'" group))) | 2238 | (setq group (substring group 0 (string-match " +\\'" group))) |
| 2235 | (setq mode (tar-grind-file-mode mode)) | 2239 | (setq mode (archive-int-to-mode mode)) |
| 2236 | ;; Move to the end of the data. | 2240 | ;; Move to the end of the data. |
| 2237 | (forward-char size) (if (eq ?\n (char-after)) (forward-char 1)) | 2241 | (forward-char size) (if (eq ?\n (char-after)) (forward-char 1)) |
| 2238 | (setq size (number-to-string size)) | 2242 | (setq size (number-to-string size)) |
| @@ -2242,7 +2246,7 @@ NAME is expected to be the 16-bytes part of an ar record." | |||
| 2242 | (if (> (length group) maxgroup) (setq maxgroup (length group))) | 2246 | (if (> (length group) maxgroup) (setq maxgroup (length group))) |
| 2243 | (if (> (length mode) maxmode) (setq maxmode (length mode))) | 2247 | (if (> (length mode) maxmode) (setq maxmode (length mode))) |
| 2244 | (if (> (length size) maxsize) (setq maxsize (length size))) | 2248 | (if (> (length size) maxsize) (setq maxsize (length size))) |
| 2245 | (push (archive-ar--file-desc extname extname nil mode | 2249 | (push (archive-ar--file-desc extname extname mode |
| 2246 | time user group size) | 2250 | time user group size) |
| 2247 | files))) | 2251 | files))) |
| 2248 | (setq files (nreverse files)) | 2252 | (setq files (nreverse files)) |