Script Library: 1238 scripts
 

pack.r

REBOL [ Title: "Pack" Date: 10-Sep-2002 Name: 'Pack Version: 1.1.2 File: %pack.r Author: "Andrew Martin" Purpose: "Self-extracting file packer & unpacker." eMail: %Al--Bri--xtra--co--nz Web: http://valley.150m.com library: [ level: 'advanced platform: none type: 'tool domain: none tested-under: none support: none license: none see-also: none ] ] make object! [ Unpacker: [ Rebol [ Name: 'Unpacker Title: "Self-extracting file unpacker." Date: (now) ] Unpack: func [Pack [block!]][ parse Pack [ some [ set File file! set Data binary! ( make paren! [ write/binary File decompress Data ] ) | set File file! ( make paren! [make-dir/deep File] ) ] end ] ] Unpack ; 'Case goes here. ] set 'Pack function [ {Self-extracting File packer & unpacker.} File [file! block!] "File can directory or block of file!" /Deep "Copy subdirectories as well." ] [ Files Block Directory ] [ append/only compose/deep Unpacker any [ if block? File [ Block: File map Block func [File [file!]] [ either #"/" = last File [ File ] [ reduce [File compress read/binary File] ] ] ] if #"/" = last File [ Directory: File map either Deep [recursive-read Directory] [read Directory] func [File [file!]] [ either #"/" = last File [ File ] [ reduce [File compress read/binary Directory/:File] ] ] ] reduce [File compress read/binary File] ] ] ]
halt ;; to terminate script if DO'ne from webpage
<< ordnum.r · pager.r >>
Notes
  • email address(es) have been munged to protect them from spam harvesters. If you are a Library member, you can log on and view this script without the munging.
  • (Al:Bri:xtra:co:nz)