DelDir

10 PRINT 'Careful!': STOP
11 :
12 ERT DelDir(#1; "ram2_", "")
13 :
100 rem + ------------------------------------------------------------------------ +
101 rem |<                                 DelDir                                 >|
102 rem + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
103 rem |                          Delete Directory Tree                           |
104 rem |                                                                          |
105 rem | Visits every node in the directory tree and, starting from the bottom,   |
106 rem | deletes each file in it, followed by the containing directory.           |
107 rem + ------------------------------------------------------------------------ +
108 rem | V0.05, pjw 2oi9                                                          |
109 rem + ------------------------------------------------------------------------ +
110 :
111 DEFine FuNction DelDir(ch, fdv$, dir$)
112 LOCal cd, lp, er, fl, ps, ty%, nm$(36)
113 :
114 cd = FOP_DIR(fdv$ & dir$): IF cd < 0: RETurn cd
115 ps = 0: er = 0: fl = FLEN(#cd)
116 REPeat lp
117  IF ps >= fl: EXIT lp
118  GET#cd\ ps + 14; nm$
119  IF LEN(nm$) > 0 THEN
120   BGET#cd\ ps + 5, ty%
121   IF ty% = 255 THEN
122    PRINT#ch; '>'! fdv$; nm$
123    er = DelDir(#ch; fdv$, nm$): IF er < 0: EXIT lp
124   ELSE
125    PRINT#ch; 'x'! fdv$; nm$
126    DELETE fdv$ & nm$
127   END IF
128  END IF
129  ps = ps + 64
130 END REPeat lp
131 CLOSE#cd
132 IF er >= 0 THEN
133  PRINT#ch; 'X'! fdv$; dir$
134  DELETE fdv$ & dir$: REMark DEL DEVn_ is ok
135 END IF
136 RETurn er
137 END DEFine  DelDir
138 :
139 :
  
Generated with sb2htm on 2019 Mar 31
©pjwitte March 2oi9