home *** CD-ROM | disk | FTP | other *** search
- /*rx
- *
- * DelFilesLhA.rexx - Delete selected files from an LhA archive previously
- * listed in a DOpus window by ListLha.rexx
- *
- * $VER: DelFilesLhA 40.8 (23/05/94) by Geoff Seeley
- *
- * Usage: ARexx command DelFilesLhA.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 '
- DeleteList = 'T:lha_file_list'
- ListLhARexx = 'RX DOpus:ARexx/ListLhA.rexx'
-
- /*--------------------------------------------------------------------------*/
-
- /* misc. variables */
-
- DOpusPort = 'DOPUS.1'
-
- LhaDeleteCmd = '-x -m d '
-
- if ~show(l,"rexxsupport.library") then
- call addlib("rexxsupport.library",0,-30,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
-
- address 'DOPUS.1'
- options results
-
- TopText "Delete Files From an LhA Archive Buffer"
-
- Busy on
-
- /* get the path/name of the LhA archive file */
-
- 'Status 14 -1'
- LhaArchive = result
-
- /* make sure it's an LhA archive listing buffer */
-
- if (IsLhAFile(LhaArchive) = 0) then do
-
- /* try other window */
-
- OtherWindow
- 'Status 14 -1'
- LhaArchive = Result
-
- if (IsLhAFile(LhaArchive) = 0) then do
-
- /* try first selected file */
-
- OtherWindow
- 'GetNextSelected -1'
- LhaArchive = RESULT
- if LhaArchive ~= 0 & IsLhaFile(LhaArchive) then do
- call SetRequester
- Request "Delete selected LhA archive?"
- DoDelete = RESULT
- Busy on
- call ReSetRequester
- if DoDelete = "1" then do
- 'Status 13 -1'
- LhaPath = RESULT
- LhaArchive = LhaPath || LhaArchive
- call DelLhArchive
- call CleanUp
- end
- end
- else do
- Notify "Sorry, no LhA archive buffer found.\You must use the ListLha button first."
- call CleanUp
- end
- end
-
- end
-
- /* get path to archive */
-
- call FindLhaPath
- LhaArchive = LhaPath || LhaArchive
-
- /* check for existance of archive */
-
- if ~exists(LhaArchive) then do
-
- Notify "Can't seem to find '" || LhaArchive || "'\Aborting."
- call CleanUp
-
- end
-
- /* check if LhA archive is empty */
-
- call GetFileCount
-
- if NumFiles = 0 then do
-
- call AskDelArchive
- call CleanUP
-
- end
-
- /* get list of selected entries */
-
- GetSelectedAll
- SelectedEntries = result
-
- if SelectedEntries = 'RESULT' then do
-
- /* no files selected, delete all? */
-
- call SetRequester
- Request "Delete *ALL* files in LhA archive?"
- DoDelete = RESULT
- Busy on
- call ReSetRequester
-
- if DoDelete = "1" then do
-
- call SetRequester
- Request "Delete LhA archive as well?"
- DelArchive = RESULT
- Busy on
- call ReSetRequester
-
- if DelArchive = "1" then do
- call DelLhArchive
- call CleanUp
- end
- else do
-
- TopText "Deleting File(s) From LhA Archive... Please Wait."
-
- CliCommand = LhaCommand||OutputWindow||LhaDeleteCmd||'"'||LhaArchive||'"'
- CliCommand = CliCommand || ' "*"'
-
- address command CliCommand
-
- NoAskDelete = 1
- call ReListArchive
- call CleanUp
- end
- end
- else do
- TopText "Deletion Of File(s) Aborted..."
- call CleanUp
- end
- end
-
- NumberOfEntries = words(SelectedEntries)
-
- /* make sure user wants it */
-
- call SetRequester
- Request "Are You *SURE* You Want to DELETE the Selected File(s)?"
- DoDelete = Result
- call ReSetRequester
-
- Busy on
-
- if DoDelete = "1" then do
-
- /* delete the files */
-
- call DeleteFileList
- call ReListArchive
- end
- else do
-
- TopText "Deletion Of File(s) Aborted..."
- call CleanUp
-
- end
-
- TopText "Finished Deleting Selected File(s) From LhA Archive."
- call CleanUp
-
- exit
-
- /*---------------------------------------------------------------------------*/
-
- DeleteFileList: /* build a list of selected files, delete list */
-
- /* toast possible old list */
-
- if exists(DeleteList) then
- delete(DeleteList)
-
- if ~open(FileList, DeleteList, 'W') then do
- Notify "Can't open file " || DeleteList
- call CleanUp
- end
-
- TopText "Creating File(s) List... Please Wait."
-
- do EntryNumber = 1 to NumberOfEntries
- Index = word(SelectedEntries, EntryNumber)
- GetEntry Index + 1
- Entry = result
- File = substr(Entry, 10)
- File = '"' || File || '"'
- call ReplaceMetaChars
- if right(File, 2) ~= '/"' then
- writeln(FileList, File)
- else
- call AskDelDir(File)
- selection = Index ||' '|| 0 ||' '|| 0
- SelectEntry selection
- end
-
- 'DisplayDir -1'
-
- close(FileList)
-
- /* form CLI command and delete the file(s) */
-
- TopText "Deleting File(s) From LhA Archive... Please Wait."
-
- CliCommand = LhaCommand||OutputWindow||LhaDeleteCmd||'"'||LhaArchive||'"'
- CliCommand = CliCommand || ' @' || DeleteList
-
- address command CliCommand
-
- 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
-
- /*---------------------------------------------------------------------------*/
-
- GetFileCount: /* get the number of files in the LhA archive */
-
- /* number of files is the second to last line */
-
- 'Status 6 -1'
- Idx = Result - 1
- GetEntry Idx
- NumFiles = word(Result, 2)
-
- return
-
- /*---------------------------------------------------------------------------*/
-
- AskDelDir: /* confirm directory deletion */
-
- call SetRequester
- Request "Delete directory "||File||" (and all files within)?"
- DelDir = RESULT
- call ReSetRequester
- Busy on
-
- if DelDir = 1 then do
- File = StripQuotes(File)
- File = '"'||File||'*"'
- writeln(FileList, File)
- end
-
- return
-
- /*---------------------------------------------------------------------------*/
-
- AskDelArchive: /* ask user if they wish to delete the archive */
-
- call SetRequester
- Request "This LhA archive is now EMPTY. Do you want to DELETE it?"
- DeleteArchive = Result
- call ReSetRequester
- Busy on
-
- if DeleteArchive = 1 then
- call DelLhArchive
-
- return
-
- /*--------------------------------------------------------------------------*/
-
- DelLhArchive: /* delete LhA archive and rescan the window */
-
- if exists(LhaArchive) then
- delete(LhaArchive)
-
- /* buffer is toast, so clear it and scan in directory */
-
- 'ClearWin -1'
- 'ScanDir "'||LhaPath||'"'
-
- TopText "LhA archive deleted."
-
- return
-
- /*--------------------------------------------------------------------------*/
-
- ReListArchive: /* relist the LhA archive after a delete */
-
- address command ListLhARexx
-
- Busy on
-
- /* get number of files left in archive */
-
- call GetFileCount
-
- if NumFiles = 0 & NoAskDelete = 0 then
- call AskDelArchive
-
- return
-
- /*--------------------------------------------------------------------------*/
-
- SetRequester: /* set requester strings */
-
- Status 26
- OldOkay = RESULT
- Status 26 set 'Delete'
- Status 27
- OldCancel = RESULT
- Status 27 set 'Cancel'
-
- return
-
- /*--------------------------------------------------------------------------*/
-
- ReSetRequester: /* reset requester strings */
-
- Status 26 set OldOkay
- Status 27 set OldCancel
-
- return
-
- /*---------------------------------------------------------------------------*/
-
- StripQuotes: procedure
-
- parse arg AFileName
-
- return strip(AFileName,, '"')
-
- /*---------------------------------------------------------------------------*/
-
- CleanUp: /* clean up files and exit */
-
- if exists(DeleteList) then
- delete(DeleteList)
-
- Busy off
- exit
-
- return
-
-