home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / oslite11.zip / unlite.cmd < prev   
OS/2 REXX Batch file  |  1994-09-20  |  3KB  |  133 lines

  1. @echo off
  2. if NOT "%@EVAL[2+2]"=="4" goto not4dos
  3. if "%OSLITE"=="" goto novar
  4.  
  5. echo Unlite V1.1 by Enrico Demarin *FREEWARE*
  6.  
  7. set TMP1=%@UNIQUE[%OSLITE]
  8. set NODEL=0
  9. set NOEAS=0
  10.  
  11. unset /Q ORG2
  12. unset /Q ORG1
  13.  
  14. if "%#"=="0" goto sum
  15. gosub scanopt
  16.  
  17. SET INFILE=%@PATH[%ORG1]%@NAME[%ORG1].cmd
  18. if NOT EXIST %INFILE goto err1
  19.  
  20. if "%ORG2"=="" goto nohd3
  21. SET OUTFILE=%@PATH[%ORG2]%@NAME[%ORG2].exe
  22. goto hdone3
  23.  
  24. :nohd3
  25. unset /Q TEST
  26. SET TEST=%@LINE[%INFILE,2]
  27. iff NOT "%@SUBSTR[%TEST,0,13]"=="SET ORIGNAME=" then goto err2
  28. endiff
  29. %TEST
  30. SET OUTFILE=%@PATH[%ORG1]%@NAME[%ORG1].exe
  31.  
  32. :hdone3
  33. unset /Q TEST
  34. SET TEST=%@LINE[%INFILE,3]
  35. iff NOT "%@SUBSTR[%TEST,0,12]"=="SET LITSIZE=" then goto err2
  36. endiff
  37. %TEST
  38. skip %LITSIZE <%INFILE >%TMP1
  39. SET SIZE=%@FILESIZE[%TMP1,b]
  40. if "%SIZE"=="0" goto err2
  41. echo Decompressing %INFILE...
  42. gzip -dcn <%TMP1 >%OUTFILE
  43. if NOT ERRORLEVEL==0 goto err3
  44.  
  45.  
  46. if "%NOEAS"=="1" goto report
  47. echo Restoring EAs...
  48. if NOT EXIST %TMP1 goto eacopy
  49. del %TMP1 >nul
  50. :eacopy
  51. eautil %INFILE %TMP1 /P /S
  52. if NOT EXIST %TMP1 goto report
  53. eautil %OUTFILE %TMP1 /O /J
  54. :report
  55. echo Done. (CMD/EXE bytes=%@FILESIZE[%INFILE,b],%@FILESIZE[%OUTFILE,b]) 
  56. if NOT EXIST %INFILE goto isdone
  57. if "%NODEL"=="1" goto isdone
  58. del %INFILE >nul
  59. :isdone
  60. goto doquit
  61.  
  62. echo File Unlited successfully. (%OUTFILE)
  63. goto doquit
  64.  
  65. :err1
  66. echo Error: source file name invalid or missing.
  67. goto sum
  68.  
  69. :err2
  70. echo Error: file isn't an OSlited executable.
  71. goto doquit
  72.  
  73. :err3
  74. echo Error: GZip returned a bad status.
  75. if NOT EXIST %OUTFILE goto sum
  76. del %OUTFILE >nul
  77. goto doquit
  78.  
  79.  
  80. :sum
  81. echo Syntax    : unlite source [destination] [-NODEL -NOEAS]
  82. echo Purpose   : decompress an Oslited  file.
  83. echo Parameters:
  84. echo            source      : cmd file to compress
  85. echo            destination : name of decompressed file,
  86. echo                          (if no name is specified, Unlite will use
  87. echo                          the name stored in the decompression header)
  88. echo            -NODEL      : don't delete the compressed file
  89. echo            -NOEAS      : don't copy .CMD extended attributes to the 
  90. echo                              destination file.        
  91. echo Requirements:
  92. echo      Unlite can work ONLY on a HPFS drive. 4OS2 2.0 or higher must 
  93. echo      be installed. And GZIP.EXE,SKIP.EXE,LTHDR.CMD must be in
  94. echo      the path.
  95.  
  96. :doquit
  97. if NOT EXIST %TMP1 goto clean1
  98. del %TMP1 >nul
  99. :clean1
  100. quit
  101.  
  102. :not4dos
  103. echo This procedure requires 4OS2 2.00 or higher.
  104. quit
  105.  
  106. :novar
  107. echo OSLITE environment not defined.
  108. quit
  109.  
  110. :scanopt
  111. SET COUNT=%#
  112. DO WHILE "%COUNT" != "0"
  113.  
  114. iff "%@UPPER[%1]"=="-NODEL" then 
  115. SET NODEL=1
  116. elseiff "%@UPPER[%1]"=="-NOEAS" then 
  117. SET NOEAS=1
  118. elseiff "%@SUBSTR[%1,0,1]"=="-" then
  119. echo Invalid option : %1
  120. elseiff "%ORG1"=="" then
  121. SET ORG1=%1
  122. elseiff "%ORG2"==""    then
  123. SET ORG2=%1
  124. else
  125. echo Extra argument %1 ignored.
  126. endiff
  127.  
  128. shift 1
  129. SET COUNT=%@EVAL[%COUNT-1]
  130. ENDDO
  131. return
  132.  
  133.