www.pudn.com > os2design4file.rar > myfind.h


#include
#include
#include
#include

void myfind(char *str1,char *str2)
{
	if(isdir(str1)==0&&isfile(str1)==0)
		printf("%s is not a file or file directory!/n",str1);
	if(isdir(str1)==1)
	{
		if(strcmp(str2,"")!=0)
		{
			int flag=0;
			char *childdir;
			DIR *dp;
			struct dirent *dirp;
			dp = opendir(str1);
			while((dirp=readdir(dp))!=NULL)
			{
				if(strcmp(str2,dirp->d_name)==0)
				{
					printf("File %s is in the %s\n",str2,str1);
					flag=1;
				}
			}
			if(flag==0)
				printf("File %s is not found\n",str2);
		}
	}
	if(isfile(str1)==1)
	{
		if(strcmp(str2,"")==0)
		{
			char buf[80];
			getcwd(buf,sizeof(buf));
			int flag=0;
			char *childdir;
			DIR *dp;
			struct dirent *dirp;
			dp = opendir(buf);
			while((dirp = readdir(dp))!=NULL)
			{
				if(strcmp(str1,dirp->d_name)==0)
				{
					printf("File %s is in the %s\n",str1,buf);
					flag=1;
				}
			}
			if(flag==0)
				printf("File %s is not found\n",str1);
		}
	}
}