首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Common Lisp中写入zip文件?

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

Stack Overflow用户
提问于 2010-11-17 19:57:07
回答 2查看 625关注 0票数 2

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

缺少CL ZIP的API

规格:

ZIP

Quicklisp

MacPorts CLISP 2.49

Aquamacs 2.1 (Emacs 23.2)

Mac OS X 10.6.4

MacBook专业版5,1

代码语言:javascript
复制
; 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>")))
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-10-05 23:57:30

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

请参阅sigil-clean.cl

票数 0
EN

Stack Overflow用户

发布于 2010-11-18 12:05:14

根据Common Lisp ZIP库的文档,您必须获得一个单独的句柄才能写入zip文件。也许您可以将内容解压缩到文件夹中,调整内容,然后通过调用(zip path-name source-folder)来压缩整个文件夹。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4204092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档