home *** CD-ROM | disk | FTP | other *** search
- program eraser;
-
- uses
- dos,crt;
- var
- i : integer;
- f : file;
- name,path : pathstr;
- ch : char;
- {--------------------------------------}
- { Recursive procedure (selfcalling) which scans given directory for files }
- { and subdirectories. If subdirectory was found, then procedure calls itself}
- { to scan new subdirectory. Also it changes file attributes to normal, so }
- { even hidden, system and read-only files will be erased. }
- procedure browse(p : string);
- var
- find : searchrec;
- begin
- writeln;
- findfirst(p+'\*.*',anyfile,find); { search given directory for file }
- if doserror=0 then { if directory not empty and while }
- while doserror=0 do { it is not empty do as follow }
- begin
- if (find.name<>'.') and (find.name<>'..') then
- begin
- if (find.attr and $10)=0 then { file found, change attr. and erase }
- begin
- name:=p+'\'+find.name;
- inc(i);
- writeln(i:3,'. ',name);
- assign(f,name);
- setfattr(f,0);
- erase(f);
- end
- else
- browse(p+'\'+find.name); { directory found, call itself }
- end;
- findnext(find);
- end;
- writeln;
- writeln('*** Removing ',p);
- rmdir(p);
- end;
- {----------------------------------------------------}
- begin { Main program body }
- clrscr;
- gotoxy(25,1);
- write('*** Andy''s Directory Eraser ***');
- writeln;
- writeln;
- if paramstr(1)='' then { No command string recieved }
- begin { ask user to enter one }
- write(' Enter directory to be erased : ');
- readln(path);
- end
- else
- path:=paramstr(1);
- for i:=1 to length(path) do
- path[i]:=upcase(path[i]);
- i:=0;
- textcolor(4);
- textbackground(7);
- writeln(' Program will remove ANY directory, even with deep subdirectories');
- writeln(' inside. Press F1 to continue or any other key to abort : ');
- ch:=readkey;
- textcolor(10); { Check if user knows what's }
- textbackground(0); { going on }
- if ch=#0 then
- ch:=readkey
- else
- halt; { Stop if F1 is not pressed }
- if ch<>#59 then
- halt;
- writeln;
- writeln(' ERASING : '); { Else report current file }
- browse(path);
- writeln;
- writeln ('That''s All ...');
- end.
-
-