home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / MOUSEDIR.ZIP / KILLDIR.KEX next >
Text File  |  1992-03-16  |  2KB  |  45 lines

  1. /* */
  2. /* Load necessasry functions from REXXUTIL package */
  3.    If RXFUNCQUERY('SysFileTree')   = 1 Then,
  4.      Call RXFUNCADD 'SysFileTree','RexxUtil','SysFileTree'
  5.    If RXFUNCQUERY('SysFileDelete') = 1 Then,
  6.      Call RXFUNCADD 'SysFileDelete','RexxUtil','SysFileDelete'
  7.    If RXFUNCQUERY('SysRmDir')      = 1 Then,
  8.      Call RXFUNCADD 'SysRmDir','RexxUtil','SysRmDir'
  9.  
  10.    Arg subdir
  11.    'DIALOG /Deleting directory' subdir' and all its files!!!/okcancel defbutton 2'
  12.    If dialog.2 <> 'OK' Then Exit 16
  13.    drc = SYSFILETREE(subdir'\*.*','dirs','ds')      /* get subdir list */
  14.    If drc <> 0 Then Do
  15.       'MSG Cannot delete' subdir'.  (RC='drc')'
  16.       Exit 28
  17.    End
  18.    frc = SYSFILETREE(subdir'\*.*','files','fs')       /* get file list */
  19.    'set reserved 11 yellow On red'
  20. /* delete all the files from the subdirs */
  21.    Do i = 1 To files.0
  22.       file = WORD(files.i,WORDS(files.i))
  23.       rc = SYSFILEDELETE(file)
  24.       If rc <> 0 Then Do
  25.          'set reserved 11' file 'not deleted.  rc from SYSRMDIR:' rc
  26.          Exit 28
  27.       End
  28.       'set reserved 11 DELETED: ' file
  29.       'refresh'
  30.    End
  31. /* must delete subdirs in reverse order */
  32.    Do i = dirs.0 To 1 By -1
  33.       dir = WORD(dirs.i,WORDS(dirs.i))
  34.       rc = SYSRMDIR(dir)
  35.       If rc <> 0 Then Do
  36.          'set reserved 11' dir 'not deleted. rc from SYSRMDIR:' rc
  37.          Exit 28
  38.       End
  39.       'set reserved 11 deleted' dir
  40.       'refresh'
  41.    End
  42.    rc = SYSRMDIR(subdir)
  43.    'set reserved 11 Off'
  44.    'msg DELETED: ' subdir
  45.