文件名称:taoqianzimulu
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:57.88kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
linux下如果目录为空目录,则只有.和.这两个也是属于目录类型的本代码使用递归来判断目录及其子目录是否为空目录
/*判断目录是否为空目录*/int IsEmptyDir(char*pszDir){DIR*pstDirp=NULL;struct dirent*pstDirStru=NULL;int ulFileNum=0;int ret=1;char szDir[100];memset(szDir,0,100);pstDirp=opendir(pszDir);if(NULL==pstDirp){printf("open dir error\n");return 0;}while(pstDirStru=readdir(pstDirp)){strcpy(szDir,pszDir);if(DT_DIR==pstDirStru-d_type){if(strcmp(pstDirStru-d_name,".")&&strcmp(pstDirStru-d_name,"."{ret=0;memset(szDir,0,100);sprintf(szDir,"s/s",pszDir,pstDirStru-d_name);IsEmptyDir(szDir);}}else{ret=0;}}closedir(pstDirp);if(ret==1){printf("s is empty dir\n",szDir);}else{printf("is not empty dir\n",szDir);}return ret;}经自己在dedora9下测试通过,希望代码能对大家有点帮助
本文来自: 高校自动化网(Www.zdh1909.com) 详细出处参考(转载请保留本链接):http://www.zdh1909.com/html/linux/12177.html-int IsEmptyDir(char*pszDir){DIR*pstDirp=NULL;struct dirent*pstDirStru=NULL;int ulFileNum=0;int ret=1;char szDir[100];memset(szDir,0,100);pstDirp=opendir(pszDir);if(NULL==pstDirp){printf("open dir error\n");return 0;}while(pstDirStru=readdir(pstDirp)){strcpy(szDir,pszDir);if(DT_DIR==pstDirStru-d_type){if(strcmp(pstDirStru-d_name,".")&&strcmp(pstDirStru-d_name,"."{ret=0;memset(szDir,0,100);sprintf(szDir,"s/s",pszDir,pstDirStru-d_name);IsEmptyDir(szDir);}}else{ret=0;}}closedir(pstDirp);if(ret==1){printf("s is empty dir\n",szDir);}else{printf("is not empty dir\n",szDir);}return ret;}
/*判断目录是否为空目录*/int IsEmptyDir(char*pszDir){DIR*pstDirp=NULL;struct dirent*pstDirStru=NULL;int ulFileNum=0;int ret=1;char szDir[100];memset(szDir,0,100);pstDirp=opendir(pszDir);if(NULL==pstDirp){printf("open dir error\n");return 0;}while(pstDirStru=readdir(pstDirp)){strcpy(szDir,pszDir);if(DT_DIR==pstDirStru-d_type){if(strcmp(pstDirStru-d_name,".")&&strcmp(pstDirStru-d_name,"."{ret=0;memset(szDir,0,100);sprintf(szDir,"s/s",pszDir,pstDirStru-d_name);IsEmptyDir(szDir);}}else{ret=0;}}closedir(pstDirp);if(ret==1){printf("s is empty dir\n",szDir);}else{printf("is not empty dir\n",szDir);}return ret;}经自己在dedora9下测试通过,希望代码能对大家有点帮助
本文来自: 高校自动化网(Www.zdh1909.com) 详细出处参考(转载请保留本链接):http://www.zdh1909.com/html/linux/12177.html-int IsEmptyDir(char*pszDir){DIR*pstDirp=NULL;struct dirent*pstDirStru=NULL;int ulFileNum=0;int ret=1;char szDir[100];memset(szDir,0,100);pstDirp=opendir(pszDir);if(NULL==pstDirp){printf("open dir error\n");return 0;}while(pstDirStru=readdir(pstDirp)){strcpy(szDir,pszDir);if(DT_DIR==pstDirStru-d_type){if(strcmp(pstDirStru-d_name,".")&&strcmp(pstDirStru-d_name,"."{ret=0;memset(szDir,0,100);sprintf(szDir,"s/s",pszDir,pstDirStru-d_name);IsEmptyDir(szDir);}}else{ret=0;}}closedir(pstDirp);if(ret==1){printf("s is empty dir\n",szDir);}else{printf("is not empty dir\n",szDir);}return ret;}
(系统自动生成,下载前可以参看下载内容)
下载文件列表
FileInfo.cpp
Resource.h
ReadMe.txt
VCHelper.h
VCHelper.cpp
StdAfx.cpp
VCHelperView.h
VCHelperView.cpp
MainFrm.h
MainFrm.cpp
FPSPropertyList.h
choosedirdlg.h
choosedirdlg.cpp
FPSPropertyListItem.h
MemDC.h
ProgressWnd.cpp
ProgressWnd.h
VCHelper.dsw
FPSPropertyList.cpp
FileInfo.h
res/
res/VCHelper.rc2
res/vssver.scc
res/Toolbar.bmp
res/VCHelper.ico
res/VCHelperDoc.ico
Release/
StdAfx.h
CodeStats.h
FPSPropertyListItem.cpp
VCHelperDoc.cpp
VCHelperDoc.h
CodeStatDlg.h
VCHelper.dsp
FileNameSearchReplaceDlg.h
CodeStatDlg.cpp
FileNameSearchReplaceDlg.cpp
SearchReplaceDlg.h
SearchReplaceDlg.cpp
VCHelper.rc
Resource.h
ReadMe.txt
VCHelper.h
VCHelper.cpp
StdAfx.cpp
VCHelperView.h
VCHelperView.cpp
MainFrm.h
MainFrm.cpp
FPSPropertyList.h
choosedirdlg.h
choosedirdlg.cpp
FPSPropertyListItem.h
MemDC.h
ProgressWnd.cpp
ProgressWnd.h
VCHelper.dsw
FPSPropertyList.cpp
FileInfo.h
res/
res/VCHelper.rc2
res/vssver.scc
res/Toolbar.bmp
res/VCHelper.ico
res/VCHelperDoc.ico
Release/
StdAfx.h
CodeStats.h
FPSPropertyListItem.cpp
VCHelperDoc.cpp
VCHelperDoc.h
CodeStatDlg.h
VCHelper.dsp
FileNameSearchReplaceDlg.h
CodeStatDlg.cpp
FileNameSearchReplaceDlg.cpp
SearchReplaceDlg.h
SearchReplaceDlg.cpp
VCHelper.rc
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.