home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
ADDEA.ZIP
/
ADDEA.CMD
next >
Wrap
OS/2 REXX Batch file
|
1992-03-28
|
4KB
|
101 lines
/*****************************************************************************/
/* ADDEA Ver 1.0 92/03/25 MIKE at HOUVMSCC */
/* */
/* ADDEA > for brief help, ADDEA ANNOUNCE for details. */
/*****************************************************************************/
'@Echo off'
Parse Arg addeaparm
addeaparm=strip(addeaparm,'B')
If addeaparm = '?' then Do
Say ' Routine to add Extended Attribute TYPE to files'
Say ' Addea [drive:]{path]filename type [/S] [/R]'
Say ' where:'
Say ' filename is the name of the file to be modified'
Say ' This may include wildcards, e.g. *.EXE'
Say ' Type is the new EA type to be added'
Say ' /S says to recursively search all subdirectories'
Say ' /R says to replace any existing types. The default is to'
Say ' add the new type.'
exit
end
If Register('SysFileTree SysSearchPath SysPutEA SysGetEA')>1 then Do
Say "Error registering REXX Utils"
Exit
End
sdopt = ''
repopt = 0
action = 'added'
if addeaparm = '' then signal tell
if addeaparm = '?' then signal tell
If Pos('/S',Translate(addeaparm),1) > 0 then sdopt = 'S'
If Pos('/R',Translate(addeaparm),1) > 0 then repopt = 1
If repopt then action = "replaced"
parse var addeaparm addeaparm1 '/s' junk
parse var addeaparm1 addeaparm2 '/S' junk
parse var addeaparm2 addeaparm3 '/r' junk
parse var addeaparm3 addeaparm4 '/R' junk
parse var addeaparm4 file newea
/* */
/* Build the list of files */
/* */
rc = SysFileTree(file, sfile, 'FO'||sdopt)
If rc<>0 then Do
Say 'File error, RC 'rc' ==> 'file
Exit
End
If sfile.0=0 then Do
Say "File "file "not found"
Exit
end
Do ifile = 1 to sfile.0
header = 'DFFF0000'x || d2c(1) || '00'x
EAs=''
If repopt=0 then Do
Call Getea
header = 'DFFF0000'x || d2c(oldea.0+1) || '00'x
EAs = ''
do j=1 to oldea.0
EAs = EAs || 'FDFF'x || d2c(length(oldea.j)) || '00'x || oldea.j
end
end
Typeinfo = header || EAs || 'FDFF'x || d2c(length(newea)) || '00'x || newea
rc = SysPutEA(Sfile.ifile,".TYPE",typeinfo)
If rc <> 0 then Do
Say "Error "rc " from SysPutEA for EA " newea " on file "Sfile.ifile
exit
end
Say "TYPE EA "newea action "to file " Sfile.ifile
end
exit
/*****************************************************************************/
/* Getea */
/* */
/* Read exiting EAs from the file */
/*****************************************************************************/
Getea: procedure expose Sfile. oldea. ifile
rc = SysGETEA(Sfile.ifile, ".TYPE", "TYPEINFO")
parse var typeinfo 5 num 6 typeinfo
oldea.0= c2d(num)
do I = 1 to oldea.0
parse var typeinfo 'FDFF'x len '00'x typeinfo
oldea.i = substr(typeinfo,1,c2d(len))
typeinfo= substr(typeinfo,c2d(len)+1)
end
Return
/*****************************************************************************/
/* Register required REXXUTIL functions. */
/* RC=0, registered. RC=1 already registered. Other=error. */
/*****************************************************************************/
Register: Procedure expose curdir
Parse arg funcs
Do j=1 to words(funcs)
rc=RxFuncAdd(word(funcs,j),'RexxUtil',word(funcs,j))
If rc>1 then
Do
Say 'Registration of 'word(funcs,j)' failed, RC 'rc
Leave j
End
End
Return rc