home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
disk
/
directory
/
dopuslharexx
/
arexx
/
addfileslha.rexx
next >
Wrap
OS/2 REXX Batch file
|
1995-02-27
|
7KB
|
378 lines
/*rx
*
* AddFilesLhA.rexx - Add the selected files to an LhA archive previously
* listed in a DOpus window by ListLha.rexx.
*
* $VER: AddFilesLhA 40.6 (03/01/94) by Geoff Seeley
*
* Usage: ARexx command AddFilesLhA.rexx (from DOpus)
*
*/
/* configuration variables (change these to suit your setup) */
LhaCommand = 'XFH_Work:C/Archivers/File/LhA '
OutputWindow = '>CON:30/145/640/100/LhA_Output/CLOSE/SCREENDOPUS.1 '
AddList = 'T:lha_file_list'
ListLhARexx = "RX DOpus:ARexx/ListLhA.rexx"
/*---------------------------------------------------------------------------*/
/* misc. variables */
DOpusPort = 'DOPUS.1'
LhaAddCmd = ''
LhaAddBase = '-m a '
LhaRecurse = '-r '
LhaSavePath = '-x '
CreateNew = 0
AddSubDirs = 0
/* 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
/* make sure the right task is listening... */
address 'DOPUS.1'
options results
TopText "Adding File(s) to an LhA Archive"
Busy on
/* get the path/name of the LhA archive file */
'Status 14 -1'
LhaArchive = result
/* if this isn't an LhA buffer, try the other window then ask for new arc. */
if (IsLhAFile(LhaArchive) = 0) then do
/* Hmm, let's try the other window */
OtherWindow
'Status 14 -1'
LhaArchive = result
/* if neither window looks right, ask for name */
if (IsLhAFile(LhaArchive) = 0) then do
call SetYesNo
Request "No LhA archive listed. Do you wish to create one?"
if Result = 0 then do
OtherWindow
TopText "Adding files to LhA archive aborted."
call CleanUp
end
else
CreateNew = 1
call RestoreRequester
/* get path of window */
'Status 13 -1'
LhaPath = Result
/* get new archive */
GetString "'Enter LhA Archive Name: (Path: '"||LhaPath||"')'"
LhaArchive = Result
/* cancel it? */
if RC = 1 then do
TopText "LhA archive creation aborted."
call CleanUp
end
if (IsLhAFile(LhaArchive) = 0) then
LhaArchive = LhaArchive || ".lha"
NewLhaArchive = LhaArchive
LhaArchive = LhaPath || LhaArchive
end
else do
/* get path to archive */
call FindLhAPath
LhaArchive = LhaPath || LhaArchive
end
end
else do
/* make sure we don't have *two* LhA buffers */
OtherWindow
'Status 14 -1'
if (IsLhAFile(result) = 1) then do
Notify "Sorry, You have two LhA archives listed.\Cannot add files from LhA archive."
OtherWindow
call CleanUp
end
OtherWindow
/* get path to archive */
call FindLhAPath
LhaArchive = LhaPath || LhaArchive
end
/* check for existance of archive */
if CreateNew = 0 then do
if ~exists(LhaArchive) then do
Notify "Can't seem to find '" || LhaArchive || "'\Aborting."
call CleanUp
end
end
/* switch to window with files to add... */
OtherWindow
/* get list of selected entries */
GetSelectedAll
SelectedEntries = result
/* must select *something* man... */
if SelectedEntries = 'RESULT' then do
Notify "Please select file(s) to add first..."
call CleanUp
end
NumberOfEntries = words(SelectedEntries)
/* get source directory */
'Status 13 -1'
SrcDir = result
/* verify, (I think I'm paranoid :-) */
if SrcDir = 'RESULT' | SrcDir = "" then do
Notify "Unable to get source directory. Aborting."
call CleanUp
end
/* ask user if they want the path included */
call SetYesNo
Request "Store pathname(s) of selected file(s) in LhA archive?"
StorePath = Result
Request "Add any possible subdirectories?"
AddSubDirs = Result
call RestoreRequester
/* form proper command */
LhaAddCmd = LhaAddBase
if StorePath = 1 then do
LhaAddCmd = LhaSavePath || LhaAddCmd
end
if AddSubDirs = 1 then do
LhaAddCmd = LhaRecurse || LhaAddCmd
end
/* add the files */
call AddFileList
/* go back to the archive window */
OtherWindow
if CreateNew = 0 then do
/* call ListLhA to re-list the LhA archive in the window */
address command ListLhARexx
end
else do
/* rescan the directory */
'Rescan -1'
/* select the new archive and list it in the window */
'Select '|| NewLhaArchive || ' onlyfiles name'
address command ListLhARexx
end
TopText "Finished adding selected file(s) to LhA archive."
call CleanUp
exit
/*---------------------------------------------------------------------------*/
AddFileList: /* build a list of selected files, add list */
/* toast possible old list */
if exists(AddList) then
delete(AddList)
if ~open(FileList, AddList, 'W') then do
Notify "Can't open file " || AddList
call CleanUp
end
TopText "Creating file(s) list..."
do EntryNumber = 1 to NumberOfEntries
/* get entry */
Entry = word(SelectedEntries, EntryNumber)
/* grab file name/path, protect in quotes */
File = '"' || Entry || '"'
/* make sure user see's the entry */
ScrollToShow Entry
/* put it in the file list */
call ReplaceMetaChars
writeln(FileList, File)
end
close(FileList)
/* form CLI command and add the file(s) */
TopText "Adding file(s) to LhA archive..."
/* move into source directory */
pragma(D, SrcDir)
CliCommand = LhaCommand || OutputWindow || LhaAddCmd || LhaArchive
CliCommand = CliCommand || ' @' || AddList
address command CliCommand
return
/*---------------------------------------------------------------------------*/
SetYesNo: /* set requester strings */
'Status 26 set Yes'
'Status 27 set No'
return
/*---------------------------------------------------------------------------*/
RestoreRequester: /* restore (default) requester strings */
Busy On
'Status 26 set Okay'
'Status 27 set Cancel'
return
/*---------------------------------------------------------------------------*/
ReplaceMetaChars: /* replace special wildcards with ? */
File = translate(File, '???', '()`', '?')
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
LhaPath = Result
return
/*--------------------------------------------------------------------------*/
CleanUp: /* clean up files and exit */
if exists(AddList) then
delete(AddList)
Busy off
exit
return