home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
disk
/
directory
/
dopuslharexx
/
arexx
/
listlha.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-02-27
|
6KB
|
275 lines
/*rx
*
* ListLhA.rexx - List and display an LhA archive file in a DOpus window
* (companion script ExtractLhaFiles.rexx will allow the user
* to select and extract files to the destination window)
*
* $VER: ListLhA 40.5 (03/01/94) by Geoff Seeley
*
* Usage: ARexx command ListLhA.rexx (from DOpus)
*
*/
/* configuration variables (change these to suit your setup) */
LhaCommand = 'XFH_Work:C/Archivers/File/LhA -x -m v '
LhaOutput = 'T:lha_out'
/*--------------------------------------------------------------------------*/
/* misc. variables */
DOpusPort = 'DOPUS.1'
LhaHeader = '--------'
userdata = ' 0' /* default */
fgpen = ' 1' /* palette 1 */
bgpen = ' 0' /* palette 2 */
selectable = ' 1' /* can select */
unselectable = ' 0' /* can't select */
show = ' 1' /* update win */
before = ' -1' /* add to end */
/* make sure we've got somebody to talk to... */
if showlist('Ports', DOpusPort) = 0 then do
say 'Directory Opus Arexx port not found. Aborting.'
call CleanUp
end
else do
/* make sure DOpus is listening to us... */
address 'DOPUS.1'
options results
/* get some information from DOpus */
Status 3
CurrentWindow = Result
/* check if window is already and LhA archive */
Status 14 CurrentWindow
LhaFileName = Result
/* if we don't see the proper extension, look at file in window */
if (IsLhAFile(LhaFileName) = 0) then do
/* get name of LhA archive file selected */
GetNextSelected CurrentWindow
LhaFileName = result
/* make sure its got the right extension */
if (IsLhAFile(LhaFileName) = 0) then do
Notify "Sorry, You *must* select an archive file\ending with '.LHA' or '.LZH'\Aborting."
TopText "List LhA archive aborted."
call CleanUp
end
/* get the directory of the LhA archive */
Status 13 CurrentWindow
LhaFilePath = result
/* make a full path/filename from above */
LhaArchive = LhaFilePath || LhaFileName
end
else do
/* get path to archive, check if it exists */
call FindLhAPath
LhaArchive = LhaFilePath || LhaFileName
if ~exists(LhaArchive) then do
Notify "Can't find LhA archive " || LhaArchive
call CleanUp
end
end
end
/* setup DOpus window and tell user what's happening */
ClearWin CurrentWindow
SetWinTitle LhaFileName
Busy on
TopText "Getting list of files from archive..."
/* make a listing file from the archive so we can parse it... */
CliString = LhaCommand || LhaArchive || ' > ' || LhaOutput
address command CliString
/* parse the list of LhA files */
call ParseLhaList
/* That's all folks... */
TopText "Finished. Select desired file(s) and extract using ExtLhaFiles button."
Busy off
call CleanUp
exit
/*---------------------------------------------------------------------------*/
ParseLhaList: /* open the listing file, and parse it */
if open(LhaList, LhaOutput, 'R') then do
/* skip the header */
junk = ''
do while left(junk, 8, '') ~= LhaHeader & ~eof(LhaList)
junk = readln(LhaList)
end
if eof(LhaList) then do
/* what the hell?? Abort. */
Notify "No files found in selected LhA archive\Aborting."
call CleanUp
end
/* read in list of files */
FileNumber = 1
line = ''
do while line ~= LhaHeader & ~eof(LhaList)
line = readln(LhaList)
/* is it a comment? junk these */
if left(line, 1) = ':' then
iterate
/* we're outta here... */
if left(line, 8, '') = LhaHeader then
leave
TopText 'Listing LhA archive. Please Wait. Parsing Entry #' || FileNumber
FileNumber = FileNumber + 1
/* extract filename/path */
FSize = substr(line, 1, 8)
FName = substr(line, 44)
File = FSize||' '||FName
/* DOpus only wants 256 chars... */
if length(File) > 255 then
File = left(File, 255)
/* need to en-case the string in quotes so ARexx passes it through unmolested... */
File = '"'||File||'"'
/* add file entry to DOpus window */
Entry = File || userdata || fgpen || bgpen || selectable || show || before
AddCustEntry Entry
end
/* grab totals */
TotalsLine = readln(LhaList)
close(LhaList)
/* add two unselectable entries for the totals */
File = '"'||LhaHeader||'"'
Entry = File || userdata || fgpen || bgpen || unselectable || show || before
AddCustEntry Entry
FSize = substr(TotalsLine, 1, 8)
FName = substr(TotalsLine, 44)
File = '"'||FSize||' '||FName||'"'
Entry = File || userdata || fgpen || bgpen || unselectable || show || before
AddCustEntry Entry
/* add invisible entry giving us the path */
File = '"'||LhaFilePath||'"'
Entry = File || userdata || bgpen || bgpen || unselectable || show || before
AddCustEntry Entry
end
else do
TopText "Can't open temp file " || LhaOutput
call CleanUp
end
return
/*--------------------------------------------------------------------------*/
IsLhAFile: procedure /* look at extension, return 1 if right, else 0 */
parse arg AFileName
lps = lastpos(".", AFileName)
if lps = 0 then
return 0
FileExt = upper(right(AFileName,length(AFileName)-lps))
if FileExt ~= "LHA" & FileExt ~= "LZH" then
return 0
else
return 1
return 0
/*--------------------------------------------------------------------------*/
FindLhAPath: /* grab invisible file path to archive */
/* find number of entries, path is the last one */
'Status 6 -1'
GetEntry Result
LhaFilePath = Result
return
/*--------------------------------------------------------------------------*/
CleanUp: /* Remove any files and exit */
if exists(LhaOutput) then
delete(LhaOutput)
Busy off
exit
return