A Common Lisp library for reading archive (tar, cpio, etc.) files
License
froydnj/archive
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
master
Could not load branches
Nothing to show
Could not load tags
Nothing to show
{{ refName }}
default
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
-
Clone
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more about the CLI.
- Open with GitHub Desktop
- Download ZIP
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
This is the README for ARCHIVE, a package for reading an writing disk-based file archives such as those generated by the 'tar' and 'cpio' programs on Unix. This package aspires to be a pure Common Lisp replacement for the 'tar' program. Current functionality includes basic extraction from and creation of tar archives. Basic extraction from certain kinds of cpio archives is also supported. ASDF packaging is provided; (asdf:oos 'asdf:load-op :archive) should be all you need to get started. Once you have the system loaded, you can try the following small example, which replicates the functionality of 'tar tf': (defun list-archive-entries (pathname) (archive:with-open-archive (archive pathname :direction :input) (archive:do-archive-entries (entry archive) (format t "~A~%" (archive:name entry))))) Access to the data for individual entries is also provided. ENTRY-STREAM returns a stream that provides access to the raw bytes of data for the entry. If you want to access it as text, you need to use a library to encode the bytes into characters, or wrap the stream using Edi Weitz's FLEXI-STREAMS. The following example prints out the first line of every file in the archive (assuming that the entry is a text file, of course): (defun first-line-of-archive-entries (pathname) (archive:with-open-archive (archive pathname :direction :input) (archive:do-archive-entries (entry archive) (when (archive:entry-regular-file-p entry) (let ((stream (flexi-streams:make-flexi-stream (entry-stream entry)))) (format t "~A~%" (read-line stream))))))) Another thing to do is create archives: ;;; This function is actually included in ARCHIVE. (defun create-tar-file (pathname filelist) (archive:with-open-archive (archive pathname :direction :output :if-exists :supersede) (dolist (file filelist (archive:finalize-archive archive)) (let ((entry (archive:create-entry-from-pathname archive file))) (archive:write-entry-to-archive archive entry))))) Note that you need to call FINALIZE-ARCHIVE once you are done adding entries. Comments, criticisms, additions, and optimizations are welcome at the below email address. Nathan Froyd froydnj@gmail.com
About
A Common Lisp library for reading archive (tar, cpio, etc.) files
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published