aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2020-04-03 13:55:50 -0400
committerStefan Monnier2020-04-03 13:58:33 -0400
commitb318e58d28cc2f88a1d64b604cad9467e3bddfa0 (patch)
tree8e78bdf347e3c75b925ad7d6428bc636b51ebd90
parent702a97ffb2cae9b739c6739cb6fb7dd18332c3e0 (diff)
downloademacs-b318e58d28cc2f88a1d64b604cad9467e3bddfa0.tar.gz
emacs-b318e58d28cc2f88a1d64b604cad9467e3bddfa0.zip
* lisp/arc-mode.el (archive-ar-write-file-member): New function
(archive-ar--name): New funtion, extracted from `archive-ar-summarize`. (archive-ar-extract): Use it. (archive-ar-summarize): Use it. Put the extname in the slot 0 of the desc vectors.
-rw-r--r--lisp/arc-mode.el37
1 files changed, 27 insertions, 10 deletions
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 796e2284af4..21b9627e407 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -56,7 +56,7 @@
56;; -------------------------------------------------- 56;; --------------------------------------------------
57;; View listing Intern Intern Intern Intern Y Y Y 57;; View listing Intern Intern Intern Intern Y Y Y
58;; Extract member Y Y Y Y Y Y Y 58;; Extract member Y Y Y Y Y Y Y
59;; Save changed member Y Y Y Y N Y N 59;; Save changed member Y Y Y Y N Y Y
60;; Add new member N N N N N N N 60;; Add new member N N N N N N N
61;; Delete member Y Y Y Y N Y N 61;; Delete member Y Y Y Y N Y N
62;; Rename member Y Y N N N N N 62;; Rename member Y Y N N N N N
@@ -101,6 +101,8 @@
101 101
102;;; Code: 102;;; Code:
103 103
104(eval-when-compile (require 'cl-lib))
105
104;; ------------------------------------------------------------------------- 106;; -------------------------------------------------------------------------
105;;; Section: Configuration. 107;;; Section: Configuration.
106 108
@@ -2145,6 +2147,17 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
2145(defconst archive-ar-file-header-re 2147(defconst archive-ar-file-header-re
2146 "\\(.\\{16\\}\\)\\([ 0-9]\\{12\\}\\)\\([ 0-9]\\{6\\}\\)\\([ 0-9]\\{6\\}\\)\\([ 0-7]\\{8\\}\\)\\([ 0-9]\\{10\\}\\)`\n") 2148 "\\(.\\{16\\}\\)\\([ 0-9]\\{12\\}\\)\\([ 0-9]\\{6\\}\\)\\([ 0-9]\\{6\\}\\)\\([ 0-7]\\{8\\}\\)\\([ 0-9]\\{10\\}\\)`\n")
2147 2149
2150(defun archive-ar--name (name)
2151 "Return the external name represented by the entry NAME.
2152NAME is expected to be the 16-bytes part of an ar record."
2153 (cond ((equal name "// ")
2154 (propertize ".<ExtNamesTable>." 'face 'italic))
2155 ((equal name "/ ")
2156 (propertize ".<LookupTable>." 'face 'italic))
2157 ((string-match "/? *\\'" name)
2158 ;; FIXME: Decode? Add support for longer names?
2159 (substring name 0 (match-beginning 0)))))
2160
2148(defun archive-ar-summarize () 2161(defun archive-ar-summarize ()
2149 ;; File is used internally for `archive-rar-exe-summarize'. 2162 ;; File is used internally for `archive-rar-exe-summarize'.
2150 (let* ((maxname 10) 2163 (let* ((maxname 10)
@@ -2167,13 +2180,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
2167 ;; Move to the beginning of the data. 2180 ;; Move to the beginning of the data.
2168 (goto-char (match-end 0)) 2181 (goto-char (match-end 0))
2169 (setq time (format-time-string "%Y-%m-%d %H:%M" time)) 2182 (setq time (format-time-string "%Y-%m-%d %H:%M" time))
2170 (setq extname 2183 (setq extname (archive-ar--name name))
2171 (cond ((equal name "// ")
2172 (propertize ".<ExtNamesTable>." 'face 'italic))
2173 ((equal name "/ ")
2174 (propertize ".<LookupTable>." 'face 'italic))
2175 ((string-match "/? *\\'" name)
2176 (substring name 0 (match-beginning 0)))))
2177 (setq user (substring user 0 (string-match " +\\'" user))) 2184 (setq user (substring user 0 (string-match " +\\'" user)))
2178 (setq group (substring group 0 (string-match " +\\'" group))) 2185 (setq group (substring group 0 (string-match " +\\'" group)))
2179 (setq mode (tar-grind-file-mode mode)) 2186 (setq mode (tar-grind-file-mode mode))
@@ -2186,7 +2193,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
2186 (if (> (length group) maxgroup) (setq maxgroup (length group))) 2193 (if (> (length group) maxgroup) (setq maxgroup (length group)))
2187 (if (> (length mode) maxmode) (setq maxmode (length mode))) 2194 (if (> (length mode) maxmode) (setq maxmode (length mode)))
2188 (if (> (length size) maxsize) (setq maxsize (length size))) 2195 (if (> (length size) maxsize) (setq maxsize (length size)))
2189 (push (vector name extname nil mode 2196 (push (vector extname extname nil mode
2190 time user group size) 2197 time user group size)
2191 files))) 2198 files)))
2192 (setq files (nreverse files)) 2199 (setq files (nreverse files))
@@ -2234,7 +2241,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
2234 (let ((this (match-string 1))) 2241 (let ((this (match-string 1)))
2235 (setq size (string-to-number (match-string 6))) 2242 (setq size (string-to-number (match-string 6)))
2236 (goto-char (match-end 0)) 2243 (goto-char (match-end 0))
2237 (if (equal name this) 2244 (if (equal name (archive-ar--name this))
2238 (setq from (point)) 2245 (setq from (point))
2239 ;; Move to the end of the data. 2246 ;; Move to the end of the data.
2240 (forward-char size) (if (eq ?\n (char-after)) (forward-char 1))))) 2247 (forward-char size) (if (eq ?\n (char-after)) (forward-char 1)))))
@@ -2247,6 +2254,16 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
2247 ;; Inform the caller that the call succeeded. 2254 ;; Inform the caller that the call succeeded.
2248 t)))))) 2255 t))))))
2249 2256
2257(defun archive-ar-write-file-member (archive descr)
2258 (archive-*-write-file-member
2259 archive
2260 (let ((d (copy-sequence descr)))
2261 ;; FIXME: Crude conversion from string modes to a number.
2262 (cl-callf (lambda (s) (if (string-match "x" s) ?\555 ?\444)) (aref d 3))
2263 d)
2264 '("ar" "r")))
2265
2266
2250;; ------------------------------------------------------------------------- 2267;; -------------------------------------------------------------------------
2251;; This line was a mistake; it is kept now for compatibility. 2268;; This line was a mistake; it is kept now for compatibility.
2252;; rms 15 Oct 98 2269;; rms 15 Oct 98