文件名称:taoqianzimulu
- 所属分类:
- Linux/Unix编程
- 资源属性:
- [Windows] [Visual C] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 58kb
- 下载次数:
- 0次
- 提 供 者:
- tian****
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
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
...\VCHelper.rc2
...\vssver.scc
...\Toolbar.bmp
...\VCHelper.ico
...\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
...\VCHelper.rc2
...\vssver.scc
...\Toolbar.bmp
...\VCHelper.ico
...\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