Category : File Managers
Archive   : BKPREVUE.ZIP
Filename : BKPREVUE.C

 
Output of file : BKPREVUE.C contained in archive : BKPREVUE.ZIP
/****************************** BKPREVUE.C ***********************************

Displays files in user-selected drive(s) which have the archive bit set.

Version 1.0 - Released August 28, 1991 by: Brian C. Peck

See accompanying READ.ME file for usage and modification information.

THIS PROGRAM CONTAINS NO WARRANTIES, EXPRESS OR IMPLIED.
*****************************************************************************/

#include
#include
#include
#include
#include

#define MAX_PATHS 512
#define MAX_DIR_OMITS 128
#define MAX_FILE_OMITS 128

/* Declare prototype functions and global variables. */

void search_directory (const char *path_name);
void get_omit_list (const char *program_path);
int compare_file_names (const char *passed_template,
const char *passed_file_name);
int compare_directory_names (const char *template,
const char *directory_name);

char path_list [MAX_PATHS] [64];
char omit_dir_list [MAX_DIR_OMITS] [64];
char omit_file_list [MAX_FILE_OMITS] [13];
int number_of_paths = 0, number_of_dir_omits = 0, number_of_file_omits = 0;

const char *backslash = "\\";
const char *all_files = "*.*";

/******************************* main *****************************************/

int main (int number_of_arguments,
char *argument[])
{
char drive_letter [27];
char drive_root [] = "d:";
int number_of_drives, drive_number, compare_result;
register int path_number, done, omit_number;

struct ffblk ffblk;

char search_path_name [68];

/* First argument, if present, is list of drives. */
/* If absent, prompt the user for the list. */

if (number_of_arguments > 1
&& strlen (argument [1]) > 0)
{
strcpy (drive_letter,argument [1]);
}
else
{
drive_letter[0] = '\0';
while (strlen (drive_letter) == 0)
{
printf ("\n\nEnter list of drive letters (no spaces, no colons):");
gets (drive_letter);
}
}

strcpy (drive_letter, strupr (drive_letter));

number_of_drives = strlen (drive_letter);

get_omit_list(argument [0]);

/*
printf ("%c[0;30;43m%c[2J",27,27);
*/

/* Search each drive. */

for (drive_number = 0;
drive_number < number_of_drives;
drive_number++)
{
drive_root [0] = drive_letter [drive_number];

search_directory (drive_root);

printf ("------------------------------------------- Drive %s\n",drive_root);

for (path_number = 0;
path_number < number_of_paths;
path_number++)
{
strcpy (search_path_name, path_list [path_number]);
strcat (search_path_name, backslash);
strcat (search_path_name, all_files);
done = findfirst (search_path_name, &ffblk, 0); /* Begin search. */

while (!done)
{
if (!(ffblk.ff_attrib & FA_DIREC) /* If not a directory */
&& (ffblk.ff_attrib & FA_ARCH)) /* and archive bit is set */
{
compare_result = 1;
for (omit_number = 0;
omit_number < number_of_file_omits;
omit_number++)
{
compare_result = compare_file_names
(omit_file_list [omit_number],
ffblk.ff_name);
if (compare_result == 0)
{
break; /* Matching file found. */
}
}
if (compare_result == 1)
{
strcpy (search_path_name, path_list [path_number]);
strcat (search_path_name, backslash);
strcat (search_path_name, ffblk.ff_name);
printf ("%s\n",search_path_name); /* Display file name. */
}
}
done = findnext (&ffblk); /* Continue search. */
}
}
number_of_paths = 0;
}

/*
printf ("\nHit %c[31;1mCtrl/C%c[0;30;43m then %c[31;1mY%c[0;30;43m to cancel.\n",
27,27,27,27);
*/

return 0;
}


/******************************* search_directory *****************************/

void search_directory (const char *path_name)
{
struct ffblk ffblk;

char search_path_name [68];

register int done, omit_number;

int compare_result;

compare_result = 1;

for (omit_number = 0;
omit_number < number_of_dir_omits;
omit_number++)
{
compare_result = compare_directory_names (omit_dir_list [omit_number],
path_name);
if (compare_result == -1)
{
return; /* Matching directory found with "..." at end. */
}

if (compare_result == 0)
{
break; /* Matching directory found. */
}
}

if (compare_result == 1)
{
strcpy (path_list [number_of_paths++], path_name); /* Add path to list. */
}

if (number_of_paths == MAX_PATHS)
{
fprintf (stderr,"\nPATH LIST FULL - Listing what fits.\n");
return;
}

strcpy (search_path_name, path_name);
strcat (search_path_name, backslash);
strcat (search_path_name, all_files);

done = findfirst (search_path_name, &ffblk, FA_DIREC); /* Begin search. */

while (!done)
{
if (ffblk.ff_name[0] != '.' /* Skip '.' and '..'. */
&& (ffblk.ff_attrib & FA_DIREC)) /* Skip if not a directory. */
{
strcpy (search_path_name, path_name);
strcat (search_path_name, backslash);
strcat (search_path_name, ffblk.ff_name);
search_directory (search_path_name); /* Call to search subdirectories. */
}
done = findnext (&ffblk); /* Continue search. */
}

return;
}


/******************************* compare_file_names ***************************/

int compare_file_names (const char *passed_template,
const char *passed_file_name)
{
static char file_name [13], template_name [13];
static char *file_extension, *template_extension, *period;

strcpy (template_name, passed_template);

period = strchr (template_name,'.');

if (period == NULL)
{
template_extension [0] = '\0';
}
else
{
period [0] = '\0';
template_extension = period + 1;
}

strcpy (file_name, passed_file_name);

period = strchr (file_name,'.');

if (period == NULL)
{
file_extension [0] = '\0';
}
else
{
period [0] = '\0';
file_extension = period + 1;
}

if (strnicmp (file_name,
template_name,
strcspn(template_name,"*")) == 0
&& strnicmp (file_extension,
template_extension,
strcspn(template_extension,"*")) == 0)
{
return 0;
}

return 1;
}


/******************************* compare_directory_names **********************/

int compare_directory_names (const char *template,
const char *directory_name)
{
static char directory_plus [67];

if (stricmp (directory_name, template) == 0)
{
return 0;
}

strcpy (directory_plus, directory_name);
strcat (directory_plus, "...");

if (stricmp (directory_plus, template) == 0)
{
return -1;
}

return 1;
}


/******************************* get_omit_list ********************************/

void get_omit_list (const char *program_path)
{
FILE *omits;

char cfg_file_name [75], omit_item [64], omit_buffer [65], *name_ptr;

if ((omits = fopen("BKPREVUE.CFG", "rt")) == NULL)
{
strcpy (cfg_file_name, program_path);
name_ptr = strrchr(cfg_file_name,'\\') + 1;
strcpy (name_ptr,"BKPREVUE.CFG");
if ((omits = fopen(cfg_file_name, "rt")) == NULL)
{
fprintf(stderr,"\nCannot find BKPREVUE.CFG - Listing all files.\n");
return;
}
}

while (fgets(omit_buffer, 65, omits) != NULL)
{
if (sscanf(omit_buffer, "%s", &omit_item) == 1)
{
if (omit_item[1] == ':')
{
strcpy (omit_dir_list [number_of_dir_omits++], omit_item);
}
else
{
strcpy (omit_file_list [number_of_file_omits++], omit_item);
}
}
}

fclose(omits);

return;
}


  3 Responses to “Category : File Managers
Archive   : BKPREVUE.ZIP
Filename : BKPREVUE.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/