°ïæ¿´Ò»ÏÂÕâ¸ö³ÌÐò¡£ÔËÐÐʱ×ÜÏÔʾ¡°¶Î´íÎó¡±
³ÌÐò×÷ÓãºÔÚ Linux Ï£¬±àд Shell ³ÌÐò£¬¼ÆËã´ÅÅÌÉÏËùÓÐĿ¼ÏÂÆ½¾ùÎļþ¸öÊý¡¢ËùÓÐĿ¼ƽ¾ùÉî¶È¡¢ËùÓÐÎļþÃûƽ¾ù³¤¶ÈJ(N0yv5t;Y{
Ô´³ÌÐò£º
#include <sys/stat.h>:a0L s7fy!F,K-zc
#include <sys/types.h>)]0R'{mMnkG,`
#include <string.h>l+W^7J Kd
#include <stdio.h>UF1z$`ah;t,S"poZ
#include <stdlib.h> r8F X"LX-X
#include <dirent.h>
int func(char*path,int* AllFileNumber,int* AllDepthNumber,
int* AllFilenameNumber,int* AllFoldNumber)Qs].eWH{._2i
{ `"g x6s^S\
struct stat statbuf;
struct dirent *dirp;
DIR *dp;
char *str1;?r7G}a _!P:l.O0]
char *str2;0E%CFjNE
int judge1;
int judge2;zF!^V/Ke9X2jIF.GZ l
int ret;M@5B0l6Z[
judge1=0;a5p(Q t ^
judge2=0;
stat(path,&statbuf);
Tv0K{ _w_
switch(statbuf.st_mode&S_IFMT)
{
case S_IFREG:
*AllFilenameNumber=strlen(path)+1;
*AllFileNumber=*AllFileNumber+1;\ D)e8rP.kdu|(M
*AllDepthNumber=*AllDepthNumber+1;
break;
case S_IFDIR: *AllDepthNumber=*AllDepthNumber+1;;}u$k/^t,J9I@
*AllFoldNumber=*AllFoldNumber+1;2b3`o{L8jR:u
dp=opendir(path);(O"kMQ y.My
while((dirp=readdir(dp))!=NULL)
{k!cv,Tv5Y1~&M gq
if((strcmp(dirp->d_name,".")==0)||(strcmp(dirp->d_name,"..")==0))E E]R+db[
if(judge1==0){
strcpy(str1,path);0ZY5f,yd:A6wo!`
judge1=1;}
if (judge2==0)I|X,z8t,O#F1a?*F
{
str2=str1+strlen(str1);
judge2=1;
}.n&TX.n`/`|S:j_
*str2++='/';Jh6I6jL)^ ?$t4l
*str2=0;
strcpy(str2,dirp->d_name); l,S&p1\4B2v:d#|{:c
ret=func(str1, AllFileNumber,AllDepthNumber,I {^ Ny}H,Y*w
AllFilenameNumber,AllFoldNumber);
*str2--;
*str2=0;&q}-{ l2@2s
}
closedir(dp); j3~M/\[?7^
break;
default: break;
}PwzO4q s3L*v3y
return 0;'t1XMH4AOXR
}YqcoL`I v|
int main(int argc,char *argv[])u7sU;\ o
{