std.fs.archive
archive
added in 3.0
(archive archive root)(archive archive root inputs)puts files into an archive
(archive “test-scratch/hello.jar” “src”) => coll?
create
added in 3.0
(create archive)creats a zip file
(fs/delete “test-scratch/hello.jar”)
(create “test-scratch/hello.jar”) => zip-system?
extract
added in 3.0
(extract archive)(extract archive output)(extract archive output entries)extracts all file from an archive
(extract “test-scratch/hello.jar”) => coll?
has?
added in 3.0
(has? archive entry)checks if the archive has a particular entry
(has? “test-scratch/hello.jar” “world.java”) => false
insert
added in 3.0
(insert archive entry input)inserts a file to an entry within the archive
(open “test-scratch/hello.jar” {:create true}) (insert “test-scratch/hello.jar” “project.clj” “project.clj”) => fs/path?
list
added in 3.0
(list archive)lists all the entries in the archive
(map str (list “test-scratch/hello.jar”)) => “/”
open
added in 3.0
(open archive)(open archive opts)either opens an existing archive or creates one if it doesn’t exist
(open “test-scratch/hello.jar” {:create true}) => zip-system?
open-and
added in 3.0
(open-and archive opts callback)helper function for opening an archive and performing a single operation
(->> (open-and “test-scratch/hello.jar” {:create false} #(protocol.archive/-list %)) (map str)) => “/”
path
added in 3.0
(path archive entry)returns the url of the archive
(-> (open “test-scratch/hello.jar”) (path “world.java”) (str)) => “world.java”
remove
added in 3.0
(remove archive entry)removes an entry from the archive
(remove “test-scratch/hello.jar” “project.clj”) => #{“project.clj”}
stream
added in 3.0
(stream archive entry)creates a stream for an entry wthin the archive
(do (insert “test-scratch/hello.jar” “project.clj” “project.clj”) (slurp (stream “test-scratch/hello.jar” “project.clj”))) => (slurp “project.clj”)
url
added in 3.0
(url archive)returns the url of the archive
(url (open “test-scratch/hello.jar”)) => (str (fs/path “test-scratch/hello.jar”))
write
added in 3.0
(write archive entry stream)writes files to an archive
(doto “test-scratch/hello.jar” (fs/delete) (open) (write “test.stuff” (binary/input-stream (.getBytes “Hello World”))))
(slurp (stream (open “test-scratch/hello.jar”) “test.stuff”)) => “Hello World”
zip-system?
added in 3.0
(zip-system? obj)checks if object is a ZipSystem
(zip-system? (open “test-scratch/hello.jar”)) => true