myfind.h

来自「设计并实现一个多用户多级目录结构的文件系统。该系统必须具备下列功能:目录操作」· C头文件 代码 · 共 55 行

H
55
字号
#include<sys/types.h>#include<dirent.h>#include<unistd.h>#include<stdio.h>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);		}	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?