Io 如何在Common Lisp中写入zip文件?

Io 如何在Common Lisp中写入zip文件?,io,zip,stream,common-lisp,Io,Zip,Stream,Common Lisp,我可以打开一个zip条目并调整内容,但我不知道如何保存它们 CL-ZIP的配置不理想 规格: 拉链 快速口齿 MacPorts CLISP 2.49 Aquamacs 2.1(Emacs 23.2) Mac OS X 10.6.4 MacBookPro 5,1 ; Removes newlines at the beginning of PRE tags in Sigil-edited ePub files. ; ; See http://code.google.com/p/sigil/issu

我可以打开一个zip条目并调整内容,但我不知道如何保存它们

CL-ZIP的配置不理想

规格:

拉链

快速口齿

MacPorts CLISP 2.49

Aquamacs 2.1(Emacs 23.2)

Mac OS X 10.6.4

MacBookPro 5,1

; Removes newlines at the beginning of PRE tags in Sigil-edited ePub files.
;
; See http://code.google.com/p/sigil/issues/detail?id=655
;
; Andrew Pennebaker
; 16 Nov 2010

; Requires Quicklisp.
; http://www.quicklisp.org/
(ql:quickload "zip")
(ql:quickload "cl-ppcre")

(defvar *epub* nil)
(defvar *epub-contents* nil)
(defvar *epub-out* nil)

(defun load-epub (filename)
  (setq *epub* (zip:open-zipfile filename)))

(defun close-epub ()
  (zip:close-zipfile *epub*)
  (setq *epub* nil)
  (setq *epub-contents* nil))

(defun gather-epub-contents ()
    (zip:do-zipfile-entries (name entry *epub*)
      (push name *epub-contents*)))

(defun is-html-file (name)
  (if (cl-ppcre:scan ".+\\.htm[l]?$" name) t nil))

(defun entry-name-to-html (name)
  (flexi-streams:octets-to-string
   (zip:zipfile-entry-contents
    (zip:get-zipfile-entry name *epub*))))

(defun clean (html)
  (values
   (cl-ppcre:regex-replace-all
    "<pre[^>]*>(\\s)*"
    (cl-ppcre:regex-replace-all "\\s+</pre>" html "</pre>")
    "<pre>")))
;删除Sigil编辑的ePub文件中预标记开头的换行符。
;
; 看见http://code.google.com/p/sigil/issues/detail?id=655
;
; 安德鲁·彭尼贝克
; 2010年11月16日
; 需要Quicklisp。
; http://www.quicklisp.org/
(ql:quickload“zip”)
(ql:quickload“cl ppcre”)
(defvar*epub*nil)
(defvar*epub内容*nil)
(defvar*epub out*nil)
(卸载加载epub(文件名)
(setq*epub*(zip:打开zipfile文件名)))
(解除关闭epub()
(邮编:close zipfile*epub*)
(setq*epub*nil)
(setq*epub内容*nil))
(取消收集epub内容()
(zip:do zipfile条目(名称条目*epub*)
(推送名称*epub内容*))
(defun是html文件(名称)
(如果(cl ppcre:scan“+\\.htm[l]?$”名称)t nil))
(将条目名称定义为html(名称)
(灵活流:八位字节到字符串)
(zip:zipfile条目内容)
(zip:get-zipfile条目名*epub*))
(defun clean(html)
(价值观
(cl ppcre:正则表达式替换所有
“]*>(\\s)*”
(cl ppcre:regex替换所有“\\s+“html”)
"")))

根据公共Lisp ZIP库的文档,您必须获得一个单独的句柄才能写入ZIP文件。也许您可以通过调用
(zip路径名称源文件夹)

将内容提取到文件夹,调整内容并压缩整个文件夹。根据公共Lisp zip库的文档,您必须获得一个单独的句柄才能写入zip文件。也许您可以将内容解压缩到文件夹,调整内容并压缩整个文件夹,只需调用
(zip路径名称源文件夹)

,使用临时文件,您就可以解压缩、修改和重新压缩


请参见使用临时文件,您可以解压缩、修改和重新压缩


请参见。但我如何才能读一个zip,然后写信给另一个(或者更好的是,写信给第一个)。但是我怎样才能读一个zip,然后写信给另一个(或者更好的是,写信给第一个)?