page%swap@Sun.COM (Bob Page) (07/12/89)
Submitted-by: cb@frambo.dec.com (Christian Balzer) Posting-number: Volume 89, Issue 162 Archive-name: util/archie18.1 Archie will copy all files that don't have the archive bit set from SOURCE and it's subdirectories to DESTINATION. If these directories don't exist at DESTINATION, Archie will try to create them on the fly preserving the original structure at SOURCE. After the file has been copied, its archive bit will be set. # This is a shell archive. # Remove anything above and including the cut line. # Then run the rest of the file through 'sh'. # Unpacked files will be owned by you and have default permissions. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: SHell ARchive # Run the following text through 'sh' to create: # archie.rexx # equal.rexx # This is archive 1 of a 1-part kit. # This archive created: Tue Jul 11 16:14:46 1989 echo "extracting archie.rexx" sed 's/^X//' << \SHAR_EOF > archie.rexx X/* Archie.rexx -- a backup utility by <CB> aka Christian Balzer X based on du.rexx by Larry Phillips. X _ _ X / / | \ \ <CB> aka Christian Balzer - The Software Brewery - X< < |-< > UUCP: decwrl!frambo.dec.com!cb OR cb@frambo.dec.com X \ \_ |_/ / CIS : 71001,210 (be brief!) | Phone: +49 6150 4151 (CET!) X------------ Mail: Im Wingertsberg 45, D-6108 Weiterstadt, F.R.G. X XUsage: [rx] Archie SOURCE DESTINATION [-options] X XSOURCE and DESTINATION are valid AmigaDOS path's WITHOUT trailing Xslashes '/'. XValid options are: Currently none... X XArchie will copy all files that don't have the archive bit set Xfrom SOURCE and it's subdirectories to DESTINATION. If these Xdirectories don't exist at DESTINATION, Archie will try to create Xthem on the fly and thus preserving the original structure at SOURCE. XAfter the file has been copied, it's archive bit will be set. X XNote: The files will be copied with 'CLONE' flag of the COPY command Xset. This of course only works with the 1.3 version of COPY. XIn this version of Archie, filenames or directories containing blanks X(like "My Dir:My File"), are NOT supported! XIn version 1.7 the form "a add" for Protect was changed to "add a" to Xsupport the ARP 1.3 protect command which isn't fully compatible. */ X X/* This is Public Domain, read the source and learn */ X Xsay 'Archie 1.8 (05-May-89) by <CB>' X X/* open the Rexx support library */ X Xif ~show('L',"rexxsupport.library") then do X if addlib('rexxsupport.library',0,-30,0) then X say 'added rexxsupport.library' X else do; X say 'support library not available' X exit 10 X end X end X Xaddress command Xcall pragma 'priority',-1 X Xarg rein X X/* The parser */ Xcopt = 'clone' X Xif words(rein) < 2 then do X say 'Come on, gimme a SOURCE *AND* a DESTINATION path' X say 'Ya better try again... Bye!' X exit 10 Xend X X Xroot = subword(rein,1,1) Xdest = subword(rein,2,1) X Xif ~ exists(root) then do X say 'Source not found' X say 'Exiting... Check your parameters' X exit 10 Xend X Xif ~ exists(dest) then do X say 'Destination not found' X say 'I''ll try to create it for you...' X 'makedir 'dest X if ~ exists(dest) then do X say 'Exiting... Check your parameters' X exit 15 X end X say 'Created 'dest Xend X Xif right(root,1) ~= ':' then X root = root || '/' Xif root = '/' then root = '' X Xif right(dest,1) ~= ':' then X dest = dest || '/' Xif dest = '/' then dest = '' X Xrlen = length(root) X Xbytes = 0 Xblocks = 0 Xfiles = 0 Xdircount = 1 X Xsay 'Archie is doing it''s job on 'root X Xcall dolist(root) X Xsay 'Archived:' bytes 'bytes,' blocks 'blocks, ', Xfiles 'files in a total 'dircount' directories.' Xsay Xexit 0 X . X X/* The real thing */ X Xdolist: procedure expose bytes blocks files dest rlen dircount copt Xparse arg x Xcontents = showdir(x); Xdo i = 1 to words(contents) X temp = x || word(contents,i) X flen = length(word(contents,i)) X type = statef(temp) X if word(type,1) = 'FILE' then X do X if substr(word(type,4),4,1) = '-' then X do X target = dest || right(temp,(length(temp) - rlen)) X target = left(target,(length(target) - flen)) X 'copy 'temp target copt X/* if RC > 0 then X say 'Error archiving 'temp X else */ X do X files = files + 1 X bytes = bytes + word(type,2) X blocks = blocks + word(type,3) + 1 X 'protect 'temp 'add a' X/* if RC > 0 then X say 'Error protecting 'temp X else */ X say 'Archived: 'temp X end X end X end X if word(type,1) ='DIR' then do X subdir = dest || right(temp,(length(temp) - rlen)) X if ~ exists(subdir) then X do X 'makedir' subdir X if ~ exists(subdir) then do X say 'Sorry... Exiting' X exit 20 X end X say ' *** Created directory' subdir X end X call dolist(temp || '/') X dircount = dircount + 1 X end Xend Xreturn SHAR_EOF echo "extracting equal.rexx" sed 's/^X//' << \SHAR_EOF > equal.rexx X/* equalize.rexx -- a utility for Archie by Christian '<CB>' Balzer X X-- _ _ X / / | \ \ <CB> aka Christian Balzer - The Software Brewery - X< < |-< > UUCP: decwrl!frambo.dec.com!cb OR cb@frambo.dec.com X \ \_ |_/ / CIS : 71001,210 (be brief!) | Phone: +49 6150 4151 (CET!) X------------ Mail: Im Wingertsberg 45, D-6108 Weiterstadt, F.R.G. X XUsage: [rx] equalize SOURCE DESTINATION [-options] X XSOURCE and DESTINATION are valid AmigaDOS path's WITHOUT trailing Xslashes '/'. XValid options are: -p This option will only print the differing X filenames, but not delete them. Use it to X see if you aren't about to destroy your work! X XEqualize will scan all files at SOURCE and it's subdirectories and Xcompare them to the files at DESTINATION and the corresponding Xsubdirectories. ALL files at DESTINATION that can't be found in XSOURCE will be DELETED!!! This goes for directory trees, too!!! X XWARNING!!! Use this beast only when you know what you're doing! :-) X XBTW, the name of this utility wasn't inspired by the TV series X"The Equalizer". Or was it? :-) X XIn this version, filenames or directories containing blanks X(like "My Dir:My File"), are NOT supported! */ X X/* This is Public Domain, read the source and learn */ X Xsay 'Equalize 1.3 (09-Feb-89) by <CB>' X X/* open the Rexx support library */ X Xif ~show('L',"rexxsupport.library") then do X if addlib('rexxsupport.library',0,-30,0) then X say 'added rexxsupport.library' X else do; X say 'support library not available' X exit 10 X end X end X Xaddress command Xcall pragma 'priority',-1 X Xarg rein X X/* The parser */ Xcopt = 'clone' X Xif words(rein) < 2 then do X say 'Come on, gimme a SOURCE *AND* a DESTINATION path' X say 'Ya better try again... Bye!' X exit 10 Xend X X Xroot = subword(rein,1,1) Xdest = subword(rein,2,1) Xdstat = 1 X Xif ~ exists(root) then do X say 'Source not found' X say 'Exiting... Check your parameters' X exit 10 Xend X Xif ~ exists(dest) then do X say 'Destination not found' X say 'Exiting... Check your parameters' X exit 15 Xend X Xif words(rein) > 2 then do X if subword(rein,3,1) = '-P' then X dstat = 0 Xend X Xif right(root,1) ~= ':' then X root = root || '/' Xif root = '/' then root = '' X Xif right(dest,1) ~= ':' then X dest = dest || '/' Xif dest = '/' then dest = '' X Xdlen = length(dest) X Xbytes = 0 Xfiles = 0 Xdircount = 1 X Xsay 'Equalize is doing it''s job on 'dest X Xcall dolist(dest) X Xsay 'Deleted:' files 'files in a total 'dircount' directories.' Xsay 'This equalization cleared:' bytes 'Bytes.' Xsay Xexit 0 X X X/* The real thing */ X Xdolist: procedure expose files root dest dlen dircount bytes dstat Xparse arg x Xcontents = showdir(x); Xdo i = 1 to words(contents) X temp = x || word(contents,i) X type = statef(temp) X if word(type,1) = 'FILE' then X do X snam = root || right(temp,(length(temp) - dlen)) X if ~ exists(snam) then X do X files = files + 1 X bytes = bytes + word(type,2) X if dstat = 1 then X do X 'delete 'temp X say 'Deleted: 'temp X end X else say 'Would have deleted: 'temp X end X end X if word(type,1) ='DIR' then do X subdir = root || right(temp,(length(temp) - dlen)) X if ~ exists(subdir) then X do X say 'Subdirectory 'subdir' not found...' X if dstat = 1 then X do X 'delete 'temp' all' X say 'Removed: 'temp X end X else say 'Would have removed: 'temp X end X call dolist(temp || '/') X dircount = dircount + 1 X end Xend Xreturn SHAR_EOF echo "End of archive 1 (of 1)" # if you want to concatenate archives, remove anything after this line exit