Fix distribution

Дата: 1997

Скачать в ZIP архиве.

/* fix distribution */
'@echo off'
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs

olddir = Directory()

lowerchr = 'abcdefghijklmnopqrstuvwxyz'
upperchr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
rootpath = 'd:\111'
flagfile = '\archlist'
fixedlist= '\fixedlst'
proclist = '\proclist'

del fixedlist
del flagfile
/* del proclist */

/* Collecting info about fixpack files */
rc = SysFileTree('fixed\*', 'file.', 'SFO', '*****', '***-*' )
if rc = 0 then do
    do i = 1 to file.0
    fl = file.i
        flpath = FileSpec('drive',fl)''FileSpec('path',fl)
        flname = FileSpec('name',fl)
        flpath = DelStr(flpath,LastPos('\',flpath))
        if flpath <> Directory() then do
            /*Say 'Directory: 'flpath*/
            newdir = Directory(flpath)
        end
        rc = LineOut( fixedlist, Translate(flname) )
    end
    rc = Stream( fixedlist, 'c', 'close' )
end

ret = Directory(olddir)


rc = SysFileTree('distr\*', 'file.', 'SFO', '*****', '***-*' )

if rc = 0 then do
    do i = 1 to file.0
    fl = file.i
        flpath = FileSpec('drive',fl)''FileSpec('path',fl)
        flname = FileSpec('name',fl)
        flpath = DelStr(flpath,LastPos('\',flpath))
        if flpath <> Directory() then do
            /* Say 'Processing distribution directory 'flpath */
            newdir = Directory(flpath)
        end
    szSignature = CharIn( flname, 1, 2 )
    rc = Stream( flname, 'c', 'close' )
    if szSignature = 'A596'X then do
        /* now let's process an archive */
        args = flname' /show 1>'flagfile
        unpack args
        rc = Stream( flagfile, 'c', 'close' )
        /* flagfile = list of files */
        /* skip name of archive */
               Call LineIn flagfile,,1
                szCNA = 'some non-empty string'
                CountOfFilesInArchive = 0
        Do While szCNA <> ''
            szCNA = LineIn( flagfile,,1 )
            if szCNA = '' then Leave
            CountOfFilesInArchive = CountOfFilesInArchive + 1
        end
        rc = Stream( flagfile, 'c', 'close' )
        /* Now we know how many files are in archive */
               Call LineIn flagfile,,1
                szCNA = 'some non-empty string'
                Do While szCNA <> ''
                    /* full path of file in archive */
            szCNA = SubStr( LineIn(flagfile,,1), 3 )
            /* path of file in archive */
                        szPA = FileSpec( 'path', szCNA )
                        /*   */
                        szNA = Translate(FileSpec( 'name', szCNA ))
                        
                        szNF = 'some another non-empty string'
                        Do While szNF <> ''
                            szNF = LineIn( fixedlist,,1)
                                if( szNF <> '' ) Then Do
                                    If szNF = szNA Then Do
                                        If CountOfFilesInArchive <= 1 then do
                                        /* add a dummy file */
                            args = rootpath'\fixed\'Translate(szNF)' 'fl' /H:DUMMY /A'
                            pack2 args
                                        end
                        args = Translate(szCNA)' 'fl' /R'
                        pack2 args
                        args = rootpath'\fixed\'Translate(szNF)' 'fl' /H:'Translate(szCNA)' /A'
                        pack2 args
                                        If CountOfFilesInArchive <= 1 then do
                                        /* remove a dummy */
                            args = 'DUMMY 'fl' /R'
                            pack2 args
                        end                        
                        Say 'Archive 'file.i
                        szT = szNF' packed to 'flpath'\'flname
                        rc = LineOut( proclist, szT )
                        Say '        'szT
                        args = rootpath'\fixed\'szNF' 'rootpath'\done'
                        copy args
                                    end
                                end        
                        end
                        rc = Stream( fixedlist, 'c', 'close' )
                end
              rc = Stream( flagfile, 'c', 'close' )
    end
    else do
    /* file in distribute is not archived, copy from fixes */
                        szNA = Translate(flname)
                        szNF = 'some another non-empty string'
                        Do While szNF <> ''
                            szNF = LineIn( fixedlist,,1)
                                if( szNF <> '' ) Then Do
                                    If szNF = szNA Then Do
                        args = ' 'rootpath'\fixed\'Translate(szNF)' 'fl
                        copy args
                        szT = '        'szNF' copied to 'flpath'\'flname
                        Say 'Nonarch 'file.i
                        Say szT
                        /* rc = LineOut( proclist, szT ) */
                        args = rootpath'\fixed\'szNF' 'rootpath'\done'
                        copy args
                                    end
                                end        
                        end
                        rc = Stream( fixedlist, 'c', 'close' )
                  rc = Stream( flagfile, 'c', 'close' )
    end
    end
end

ret = Directory(olddir)