C/C++ 路径为目录判断
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
/****************************************************
* 函数功能: 判断参数路径是否为(正确的)目录
* 函数返回: 0为表示路径为文件,1为非目录.其他为错误
* 参数: path文件需要判断的目录的路径.
* 可以为相对路径.
*
*****************************************************/
int isDir(const char *path)
{
struct stat info;
if ( 0 != stat(path,&info) )
{
return -2;
}
if( info.st_mode & S_IFDIR )
{
return 0;
}
else
{
return 1;
}
}
相关文档:
Boss说,要看OpenGL,看了快一个月,总算出了个像样的东西,用C写了个3D迷宫,
虽然只有350行
代码,不过边学边写,足足写了一周时间,还是小有成就感的,活活活!
&n ......
一、XML只有一个Table的情况
(1)userInfo.xml
<?xml version="1.0" encoding="utf-8" ?>
<UserInfo ......
#include <list.h>
#include <dirent.h>
#include <iostream.h>
#include <sys/stat.h>
#include <sys/types.h>
/*****************************************************************
*函数功能: 目_录_遍_历.
*返回值: 成功返回0,失败返回非0.
*参数 path ......