Документ взят из кэша поисковой машины. Адрес оригинального документа : http://crydee.sai.msu.ru/ftproot/users/asv/misc/rxdiff/rxdiff.cmd
Дата изменения: Sat Mar 2 20:04:26 1996
Дата индексирования: Mon Dec 24 05:21:49 2007
Кодировка:
/* */
"@echo off"

parse arg oldlist newlist .

if newlist = "" then exit

say "old listing is '"oldlist"'"
say "new listing is '"newlist"'"

removebatch = "rm"newlist"-"oldlist".cmd"
addbatch = "cp"newlist"-"oldlist".cmd"

signal off notready

say "reading '"oldlist"'..."
call stream oldlist, "C", "OPEN READ"
do numold=1 by 1
l = linein(oldlist)
if l = "" then leave
parse var l dt tm sz nm
old.numold = nm
old.nm.date = maketimestamp(dt tm)
old.nm.size = sz
end
numold = numold - 1
call stream oldlist, "C", "CLOSE"

say "reading '"newlist"'..."
call stream newlist, "C", "OPEN READ"
do numnew=1 by 1
l = linein(newlist)
if l = "" then leave
parse var l dt tm sz nm
new.numnew = nm
new.nm.date = maketimestamp(dt tm)
new.nm.size = sz
end
call stream newlist, "C", "CLOSE"
numnew = numnew - 1
say numold"/"numnew "lines in old/new lists"
drop dt tm sz nm

say "generating list of files to be removed from the old archive..."
"rm -f" removebatch
call stream removebatch, "C", "OPEN WRITE"
do i=1 to numold
name = old.i
/* say new.name.date ":" new.name".DATE" */
/* say new.name.date ":" old.name.date */
if (new.name.date = new.name".DATE") |,
(new.name.date <> old.name.date) |,
(new.name.size <> old.name.size) then call lineout removebatch, "rm" name
end
call stream removebatch, "C", "CLOSE"

say "generating list of files to be added to the old archive..."
"rm -f" addbatch
call stream addbatch, "C", "OPEN WRITE"
prevdirname = " "
do i=1 to numnew
name = new.i
if (old.name.date = old.name".DATE") |,
(new.name.date <> old.name.date) |,
(new.name.size <> old.name.size) then do
dirname = filespec("P", name)
if (dirname <> " ") & (prevdirname <> dirname) then
call lineout addbatch, "mkdir1 -p "dirname
call lineout addbatch, "cp %1/"name name
prevdirname = dirname
end
end
call stream addbatch, "C", "CLOSE"

exit /* finally */

/* ----------------------------------------------------------------------- */

maketimestamp: procedure
parse arg dt tm
year = substr(right(dt,8),7,2)
month = substr(right(dt,8),4,2)
day = substr(right(dt,8),1,2)
hour = substr(right(tm,6),1,2)
min = substr(right(tm,6),4,2)
if substr(month,1,1) = " " then month = "0"substr(month,2,1)
if substr(right(tm,6),6,1) = "p" then hour = hour+12
if length(hour) = 1 then hour = "0"hour
if substr(hour,1,1) = " " then hour = "0"substr(hour,2,1)
/* say "maketimestamp: returning" "A"year||month||day||hour||min */
return "A"year||month||day||hour||min