home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / zp2exc.zip / ZIP2EXE.CMD < prev   
OS/2 REXX Batch file  |  1994-10-19  |  4KB  |  108 lines

  1. /**********************************************************************/
  2. /*         REXX program to simulate PKZip's ZIP2EXE program           */
  3. /*                                                                    */
  4. /* 10/19/94 - Initial REXX program released to public domain.         */
  5. /*            Original program written by Jaime A. Cruz, Jr.          */
  6. /*            (72267.1372@compuserve.com)                             */
  7. /*                                                                    */
  8. /**********************************************************************/
  9. '@ECHO OFF'
  10.  
  11. /**********************************************************************/
  12. /*      Set variable with pathname to UNZIPSFX.EXE                    */
  13. /**********************************************************************/
  14. stub = 'C:\PK\UNZIPSFX.EXE'
  15.  
  16. /**********************************************************************/
  17. /*      Extract the name of the .ZIP archive file                     */
  18. /**********************************************************************/
  19. Parse Upper Arg zipfile .
  20. If zipfile = '' Then
  21.    Do
  22.       Say 'Usage:  ZIP2EXE ZipFile'
  23.       Say ''
  24.       Say 'Where ZipFile is the filename of the ZIP file you want to create a'
  25.       Say 'Self-Extracting file from.  Default extension is .ZIP if none is given.'
  26.       Exit 0
  27.    End
  28.  
  29. /**********************************************************************/
  30. /*            Initialize REXXUtil environment (if not present)        */
  31. /**********************************************************************/
  32. rxload = RxFuncQuery('SysLoadFuncs')
  33. If rxload Then
  34.    Do
  35.       Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  36.       Call sysloadfuncs
  37.    End
  38.  
  39. /**********************************************************************/
  40. /*      Validate all of the passed file names                         */
  41. /**********************************************************************/
  42. zipdrv = Filespec('D',zipfile)
  43. zippth = Filespec('P',zipfile)
  44. zipnam = Filespec('N',zipfile)
  45. period = Pos('.', zipnam)
  46. If period <> 0 Then
  47.    Do
  48.       zipfn = Substr(zipnam, '1', (period - 1))
  49.       zipft = Substr(zipnam, (period + 1))
  50.    End
  51. Else
  52.    Do
  53.       zipfn = zipnam
  54.       zipft = 'ZIP'
  55.    End
  56. zipfull = zipdrv||zippth||zipfn||'.'||zipft
  57. sfxfull = zipfn||'.EXE'
  58.  
  59. rc = SysFileTree(stub,    stexist, 'F')
  60. rc = SysFileTree(zipfull, zfexist, 'F')
  61. rc = SysFileTree(sfxfull, sfexist, 'F')
  62. Select
  63.    When (\ stexist.0) Then
  64.       Do
  65.          Say stub 'not found -- verify location of UNZIPSFX.EXE and'
  66.          Say 'modify ZIP2EXE.CMD accordingly.'
  67.          result = 4
  68.       End
  69.    When (\ zfexist.0) Then
  70.       Do
  71.          Say zipfull 'does not exist -- CMD file ending.'
  72.          result = 4
  73.       End
  74.    When (sfexist.0) Then
  75.       Do
  76.          Say sfxfull 'exists -- Overwrite?  (Y/N)'
  77.          ans = SysGetKey('ECHO')
  78.          If ans = 'Y' | ans = 'y' Then
  79.             Do
  80.                'DEL' sfxfull '>NUL'
  81.                result = 0
  82.             End
  83.          Else
  84.             result = 4
  85.          Say ''
  86.       End
  87.    Otherwise
  88.       result = 0
  89. End
  90.  
  91. /**********************************************************************/
  92. /*      All names parsed.  Create the self-extractor                  */
  93. /**********************************************************************/
  94. If result = 0 Then
  95.    Do
  96.       'COPY /B' stub||'+'||zipfull sfxfull '>NUL'
  97.       result = rc
  98.       If result = 0 Then
  99.          Say sfxfull 'successfully created.'
  100.    End
  101.  
  102. /**********************************************************************/
  103. /*      If we loaded REXXUtil, unload it, then exit.                  */
  104. /**********************************************************************/
  105. If rxload Then
  106.    Call SysDropFuncs
  107. Exit result
  108.