home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / csinst.zip / delsaves.cmd < prev    next >
OS/2 REXX Batch file  |  1996-05-28  |  4KB  |  116 lines

  1. /* REXX *********************************************/
  2. /*                                                  */
  3. /* Program name: DELSAVES                           */
  4. /* Function    : Delete Backup after successfully   */
  5. /*               installation                       */
  6. /*               example for the post-install-      */
  7. /*               successful exit                    */
  8. /*                                                  */
  9. /* Syntax      : Call from the INSTALL.DAT via:     */
  10. /*    START_REXX_BY_SUCCESSFUL=DELSAVES dest_path   */
  11. /*                                                  */
  12. /* Changes     :                                    */
  13. /*                                                  */
  14. /* Made use of GREED.  21 May 1996 / 21:22:36   JRK */
  15. /****************************************************/
  16. Parse Arg destPath
  17. /*-------------(Write lines into file)--------------*/
  18. myLog = destPath'\install.log'
  19. rc = LineOut( myLog, 'Destination Directory:' destPath)
  20.  
  21. /*==============(Exception handling)================*/
  22. Signal On Failure Name CLEARUP
  23. Signal On Halt    Name CLEARUP
  24. Signal On Syntax  Name CLEARUP
  25.  
  26. /*==========(Initialize RexxUtil support)===========*/
  27. If RxFuncQuery('SysLoadFuncs') Then Do
  28.   Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  29.   Call SysLoadFuncs
  30. End /* If RxFuncQuery... */
  31.  
  32. /*--------------(Save directory)---------------*/
  33. directory = destPath||'\SAVEPREV'
  34.  
  35. /* Call HandleFNC(directory, destPath, myLog) */
  36.  
  37. /*-----------(Find file/Set attributes)-------------*/
  38. rc = SysFileTree( directory||'\*.*', fileList, 'FO' )
  39. Do i = 1 To fileList.0
  40.   /*------------------(Delete file)-------------------*/
  41.   delRC = SysFileDelete( fileList.i )
  42. End /* If ... */
  43.  
  44. /*-------------(Remove directory)--------------*/
  45. rc = SysRmDir( directory )
  46.  
  47. /*================(End this program)================*/
  48. Return
  49.  
  50. CLEARUP:
  51.   Say 'GREED001E - Break, Failure or Syntax Error'
  52. Return
  53.  
  54. /*================(Search FNC files)================*/
  55. CheckFNC: Procedure
  56. Arg destPath, filename
  57.  
  58. /*----------------(Split path name)-----------------*/
  59. name = FileSpec( "Name", filename )  /* FILENAME.EXT */
  60. newFNC = destPath||'\'||name
  61. rc = SysFileTree( newFNC, List )
  62. If List.0 > 0 Then Return newFNC
  63. Else rc = LineOut( myLog, 'No FNC' name 'found' )
  64.  
  65. Return ''
  66.  
  67.  
  68. /*================(Copy FNC files)=================*/
  69. CopyFNC: Procedure
  70. Arg oldFNC, newFNC
  71.  
  72. appl.0 = 0
  73. key.0 = 0
  74. result = SysIni( oldFNC, 'ALL:', 'appl' )
  75. Do i = 1 To appl.0
  76.   result = SysIni( oldFNC, appl.i, 'ALL:', 'key' )
  77.   Do j = 1 To key.0
  78.     value = SysIni( oldFNC, appl.i, key.j )
  79.     /*---------------(Set key value data)---------------*/
  80.     result = SysIni( newFNC, appl.i, key.j, value )
  81.     If result = 'ERROR:' Then Do
  82.       Queue 'APPL' i appl.i 'KEY' j key.j result
  83.       Parse Var newFNC name '.' ext
  84.       renFNC = name || '.' || 'FUN'
  85.       "ren" newFNC renFNC
  86.       Return result
  87.     End
  88.   End
  89. End
  90.  
  91. Return 'OK:'
  92.  
  93.  
  94. /*===============(Handle FNC files)=================*/
  95. HandleFNC: Procedure
  96. Arg directory, destPath, myLog
  97.  
  98. /*-----------(Find previous *.FNC files)------------*/
  99. appl.0 = 0
  100. rc = SysFileTree( directory||'\*.FNC', fileList, 'FO' )
  101. rc = LineOut( myLog, 'FNC files:' fileList.0 )
  102.  
  103. Do i = 1 To fileList.0
  104.   newFNC = CheckFNC(destPath, fileList.i)
  105.   rc = LineOut( myLog, 'From:' fileList.i 'to:' newFNC)
  106.   If newFNC > '' Then Do
  107.     Call CopyFNC fileList.i, newFNC
  108.     If result = 'ERROR:' Then Do
  109.       Pull erRecord
  110.       rc = LineOut( myLog, erRecord )
  111.     End
  112.   End
  113. End
  114. status = Stream( myLog, 'C', 'Close' )
  115.  
  116. Return