/***************************************************************************/
/***************************************************************************/
/** NUKE by Chris Knight, Hobbiest Date: 03/15/91 **/
/** **/
/** PROGRAM ID. DIRECTORY TREE 'NUKE' (VERSION 1.1) **/
/** **/
/** AUTHOR. CHRIS KNIGHT **/
/** **/
/** INSTALLATION. TECHNICAL ASPECTS **/
/** **/
/** COMPUTER & SYSTEM. HACKED 386, COMPAQ DOS 3.31 **/
/** **/
/** ALGORITHM REFERENCE. (NONE) **/
/** **/
/** DOCUMENTATION REFERENCE. TURBO C, THE COMPLETE REFERENCE **/
/** **/
/** REMARKS. THIS PROGRAM WILL REMOVE A DIRECTORY AFTER DELETING THE **/
/** FILES CONTAINED WITHIN. BY USING A RECURSIVE STRUCTURE, **/
/** THIS PROGRAM WILL REMOVE ENTIRE DIRECTORY TREES. **/
/** **/
/** VERSION 1.1 WILL NOW REMOVE HIDDEN AND PROTECTED FILES. **/
/** **/
/***************************************************************************/
/***************************************************************************/
#include "dos.h"
#include "dir.h"
#include "stdio.h"
main(argc,argv)
int argc;
char *argv[];
{
char answer;
if ( argc == 1 )
{
printf("\nNUKE! By Chris Knight,");
printf("\n Sysop of Pacific Tech:");
printf("\n 219/922-1382\n\n");
printf("\nUsage: NUKE directory_name <ENTER>");
printf("\n Where directory_name is the");
printf("\n DIR you wish to remove.\n");
return(1);
}
printf("\nAre you sure you wish to NUKE the \"%s\" DIR? ", argv[1]);
answer = getche();
if ( (answer == 'y') | (answer == 'Y') )
{
if (nuke(argv[1]) == 0)
printf("\nExecuted with no errors.\n\n");
else
printf("\nExited with an error.\n\n");
}
else
printf("\nBetter safe than sorry!\n");
}
nuke(directory)
char *directory;
{
struct ffblk f;
register int done;
if ( chdir(directory) != 0 )
{
printf("\nDirectory %s does not exist.", directory);
return(1);
}
if ( erase() != 0 )
return(2);
done = findfirst("*.*", &f, FA_DIREC);
while (!done)
{
if ( (f.ff_attrib == FA_DIREC) & (*f.ff_name != '.') )
if ( nuke(f.ff_name) != 0 )
return(3);
done = findnext(&f);
}
chdir("..");
if ( rmdir(directory) != 0 )
{
printf("\nUnable to remove directory: %s", directory);
printf("\nHidden files present?");
return(4);
}
}
erase()
{
struct ffblk f;
register int done;
done = findfirst("*.*", &f, 0);
while (!done)
{
if ( remove(f.ff_name) != 0)
{
printf("\nUnable to erase file: %s", f.ff_name);
printf("\nRead Only?");
return(1);
}
done = findnext(&f);
}
return(0);
}