home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Security / Security.zip / swp401.zip / DELDIR.CMD < prev    next >
OS/2 REXX Batch file  |  1994-08-08  |  5KB  |  150 lines

  1. /*--------------------------------------------------------------------------
  2. **
  3. ** Copyright (c) 1994 Syntegration
  4. **
  5. ** wprest.cmd
  6. **
  7. ** Function:   Workplace restore command file
  8. **             this procedure restores the workplace file from a backup
  9. **             directory in a drive other than your boot drive
  10. **------------------------------------------------------------------------*/
  11. ARG   user_dir
  12. /*--------------------------------------------------------------------------
  13. ** Load the REXX Utility functions
  14. **------------------------------------------------------------------------*/
  15.  
  16. CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
  17. CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
  18. CALL RxFuncAdd 'SysRmDir', 'RexxUtil', 'SysRmDir'
  19. CALL RxFuncAdd 'SysGetKey', 'RexxUtil', 'SysGetKey'
  20.  
  21.  
  22. /*----------------------------------------------------------------------
  23. ** Load text strings for SysFileDel and SysRmDir return codes.
  24. ** then display the logo
  25. **----------------------------------------------------------------------*/
  26.  
  27. CALL LoadDELRCText
  28. CALL LoadRDRCText
  29.  
  30.  
  31. /*-------------------------------------------------------------------------
  32. **
  33. ** Function:      DelDir
  34. **
  35. ** Description:  Deletes all files and subdirectories in the target,
  36. **                then it deletes the target directory.
  37. **
  38. **-----------------------------------------------------------------------*/
  39.  
  40. /*-------------------------------------------------------------------------
  41. ** Check to make sure the directory exists -
  42. ** If it does prompt the user to make sure they really want to do this.
  43. ** Otherwise issue a message and exit
  44. **-----------------------------------------------------------------------*/
  45. IF LENGTH(STRIP(user_dir, 'B')) > 0 THEN
  46. DO
  47.    rc = SysFileTree( user_dir, dir_list, 'D')
  48.    IF dir_list.0 = 0  THEN
  49.    DO
  50.       SAY user_dir' not found.'
  51.       exit
  52.    END
  53.  
  54.    DROP dir_list.
  55.  
  56.    /*-----------------------------------------------------------------------
  57.    ** Mark all the read-only files to be non read-only
  58.    **---------------------------------------------------------------------*/
  59.  
  60.    rc = SysFileTree( user_dir, dir_list, 'BO', '****','----')
  61.  
  62.    DROP dir_list.
  63.  
  64.    /*-----------------------------------------------------------------------
  65.    ** Go through the list of files and delete each one
  66.    **---------------------------------------------------------------------*/
  67.  
  68.    rc = SysFileTree( user_dir || '\*.*', dir_list, 'FSO' )
  69.    DO x = 1 TO dir_list.0
  70.       rc = SysFileDelete(dir_list.x)
  71.       SAY dir_list.x '........' DELRCText.RC
  72.    END
  73.  
  74.    DROP dir_list.
  75.  
  76.    /*-----------------------------------------------------------------------
  77.    ** Go through all the subdirectories and remove them.
  78.    ** We go backwards through the list in order to delete the
  79.    ** lowest level sudirectories first and work our way back up
  80.    ** the tree.
  81.    **---------------------------------------------------------------------*/
  82.  
  83.    rc = SysFileTree(user_dir || '\*.*', dir_list, 'DSO')
  84.  
  85.    DO x = dir_list.0 TO 1 BY -1
  86.  
  87.       rc=SysRmDir( dir_list.x )
  88.       SAY dir_list.x '........' RDRCText.RC
  89.  
  90.    END
  91.  
  92.    DROP dir_list.
  93.  
  94.    /*-----------------------------------------------------------------------
  95.    ** Delete the directory the user passed
  96.    **---------------------------------------------------------------------*/
  97.  
  98.    rc = SysRmDir( user_dir )
  99.    SAY user_dir '........' RDRCText.RC
  100.  
  101. END
  102.  
  103. exit
  104.  
  105.  
  106. /*-------------------------------------------------------------------------
  107. **
  108. ** Function:      LoadDELRCText
  109. **
  110. ** Description:   Provides text strings for SysFileDel return codes
  111. **
  112. **-----------------------------------------------------------------------*/
  113.  
  114. LoadDELRCText:
  115.  
  116.    DELRCText.0    = 'File deleted successfully. '
  117.    DELRCText.2    = 'Error.  File not found. '
  118.    DELRCText.3    = 'Error.  Path not found. '
  119.    DELRCText.5    = 'Error.  Access denied. '
  120.    DELRCText.26   = 'Error.  Not DOS disk. '
  121.    DELRCText.32   = 'Error.  Sharing violation. '
  122.    DELRCText.36   = 'Error.  Sharing buffer exceeded. '
  123.    DELRCText.87   = 'Error.  Invalid parameter. '
  124.    DELRCText.206  = 'Error.  Filename exceeds range error. '
  125.  
  126. RETURN
  127.  
  128. /*-------------------------------------------------------------------------
  129. **
  130. ** Function:      LoadRDRCText
  131. **
  132. ** Description:   Provides text strings for SysRmDir return codes
  133. **
  134. **-----------------------------------------------------------------------*/
  135.  
  136. LoadRDRCText:
  137.  
  138.    RDRCText.0     = 'Directory removed successfully. '
  139.    RDRCText.2     = 'Error.  File not found. '
  140.    RDRCText.3     = 'Error.  Path not found. '
  141.    RDRCText.5     = 'Error.  Access denied. '
  142.    RDRCText.16    = 'Error.  Current Directory. '
  143.    RDRCText.26    = 'Error.  Not DOS disk. '
  144.    RDRCText.87    = 'Error.  Invalid parameter. '
  145.    RDRCText.108   = 'Error.  Drive locked. '
  146.    RDRCText.206   = 'Error.  Filename exceeds range error. '
  147.  
  148. RETURN
  149.  
  150.