UTILS\FINDFILE.C  ·  C  ·  779 B  ·  1991-12-01  ·  from PCPlus_Issue-63_Dec-1991_FluxEngine-360Kb
#include "stdio.h"
#include "dir.h"

char old_dir[100],current_dir_name[100];
void searchdir(char *);

main()
{
	getcwd(old_dir,100);
	chdir("\\");
	searchdir("*.*");
	chdir(old_dir);
}

void searchdir(filespec)
char *filespec;
{
	struct ffblk findblock;

	getcwd(current_dir_name,100);

	if (findfirst(filespec,&findblock,0x2f) == 0)
	{
		do
		{
			printf("%s - ",current_dir_name);
			printf("%s\n",findblock.ff_name);
		} while (findnext(&findblock) != -1);
	}

	if (findfirst("*.*",&findblock,0x33) == 0)
	{
		do
		{
			if (findblock.ff_attrib & 0x10)
			{
				if (*findblock.ff_name != '.')
				{
					chdir(findblock.ff_name);
					searchdir(filespec);
					chdir("..");
				}
			}
		} while (findnext(&findblock) != -1);
	}
}