/* Script to Convert lha archives to lzx archives */ /* C J Hewitt 4/8/95 lha2lzx Version 1.00 */ Parse Arg Archive Options TempDir = '' /* Temp Directory */ Nil = '' /* For Quiet option */ /* Set error handling code */ Signal On Error Signal On Break_C if Archive = '?' then do say 'Valid Options: [rx] lha2lzx [Temp ] [Delete] [Quiet]' exit end if Archive = '' then do say "lha2lzx: You must enter an archive" exit end if ~exists(Archive) then do say "lha2lzx: Cannot open "Archive". Object not found" exit end /* Separate filename from path */ Dev = '' Parse Var Archive Dev ':' Rest if Rest = '' & Dev ~= '' then do Rest = Dev Dev = '' end Path = '' PPath = '' do while (Rest ~= "") Parse Var Rest PPath '/' Rest if Rest ~= "" then do if Path = "" then Path = PPath else Path = Path || '/' || PPath end end if Dev = '' then FullPath = Path else FullPath = Dev || ':' || Path if Path ~= '' then FullPath = FullPath || '/' FileName = PPath /* Determine if valid filename (ie does it end in .lha */ if Upper(Right(FileName,3)) ~= 'LHA' then do say "Not a valid lha archive name" exit end Delete = FALSE Temp = "" do while (Options ~= "") Parse Upper value Options with Opt Options if Opt = "TEMP" then parse value Options with Temp Options if Opt = "DELETE" then Delete = TRUE if Opt = "QUIET" then Nil = '> Nil:' end if Temp = "" then Temp = "T:" if Right(Temp, 1) = ":" | Right(Temp, 1) = "/" then Slash = "" else Slash = "/" Temp = Temp || Slash /* get basename of Archive */ Basename = Left(Filename,Length(FileName)-4) TempDir = Temp"lha"Random(,,time(s))"/" dummy=PRAGMA('D',FullPath) FullPath = PRAGMA('D') /* Get actual path in case relative paths have been used */ if Right(FullPath,1) ~= ":" then FullPath = FullPath'/' address command say "Unarchiving" Archive "To Temp Directory......" 'lha x' FileName TempDir Nil say "Creating lzx Archive......." dummy=PRAGMA('D',TempDir) /* Change to Temp Directory */ 'lzx a -r 'FullPath || BaseName || '.lzx' '#?' Nil address rexx /* Gets confused with next line if using Ram Disk: as temp dir if we don't do this */ dummy=PRAGMA('D',FullPath) /* Change to start dir so we can delete temp directory & delete orignal archive if required */ address command /* Now we can switch back to AmigaDOS */ 'delete' TempDir 'all quiet' /* If Delete has been specified on command line then delete original file */ if Delete = TRUE then 'delete' FileName exit /* Error Handling Code */ Break_C: Error: ErrStr = "lha2lzx: Conversion Failed." if Delete = TRUE then ErrStr = ErrStr "Original Archive Not Deleted." Say ErrStr dummy = PRAGMA('D','SYS:') /* Change to 'safe' directory */ if TempDir ~= '' & Exists(TempDir) then do address command 'delete' Temp 'all quiet' end exit(30)