Category : File Managers
Archive   : ~DEL2.ZIP
Filename : ~DEL.C

 
Output of file : ~DEL.C contained in archive : ~DEL2.ZIP
#include
#include
#include
#include
#include

#define MAXPATH 80

int pathlen = 0;

int qcompare (const char *a, const char *b)
{
const char **x = a, **y = b;

return stricmp (*x, *y);
}
int bcompare (const char *a, const char *b)
{
const char *x = a, **y = b;

return strnicmp (x, *y + pathlen, strlen (x));
}

main (int argc, char *argv [])
{
int done;
struct ffblk fname;
char *p = NULL, path [MAXPATH];

// print syntax if called with no args

if (argc == 1) {
printf ("~DEL 1.0\n");
printf ("Copyright 1992, Michael A. Veve\n");
printf ("Usage:\n");
printf ("\t~DEL filespec ...\n\n");
printf ("Delete all files that do not match filespec where filespec is any DOS file\n");
printf ("name with wildcards (path optional)\n\n");
printf ("Filespecs with no paths specified assume the current directory\n\n");
printf ("Handle with care!\n");
return 0;
}

// find pathname of first argument

if (p = strrchr (argv [1], '\\'))
strncpy (path, argv [1], pathlen = p - argv [1] + 1);
path [pathlen] = 0;

// sort command line arguments

qsort ((void *) (argv + 1), argc - 1, sizeof (argv [0]), qcompare);

/* go thru entire directory trying to match
file names to sort argument list */

done = findfirst (strcat (path, "*.*"), &fname, FA_ARCH);
while (!done) {

// is there a match?

if (!bsearch ((void *) fname.ff_name, (void *) (argv + 1), argc - 1, sizeof (argv [0]), bcompare)) {

// construct full path name and delete!

strcpy (path + pathlen, fname.ff_name);
remove (path);
}

// next victim

done = findnext (&fname);
}

// return to DOS

return 0;
}


  3 Responses to “Category : File Managers
Archive   : ~DEL2.ZIP
Filename : ~DEL.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/