yeqing

C++博客 首页 新随笔 联系 聚合 管理
  1 Posts :: 14 Stories :: 10 Comments :: 0 Trackbacks

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
extern int errno;
int CheckFileExit(const char *szFileName)
{
  struct stat st;
   if(lstat(szFileName,&st)!= -1)
   {
      return 0;
   }
   else if(errno==ENOENT)
   {
      return -1;
   }
 return -2;
}

int main( int argc, char* argv[] )
{
    char pReturnUrl[100]={0};
    int nResault=0;
 
    if(argc!=2)
    {
        printf("缺少文件名\n");
        return -1;
    }
    nResault=CheckFileExit(argv[1]);
    printf("访问文件名为:%s\n",argv[1]);
    printf("访问结果为:%d\n",nResault);
    return 0;
}

posted on 2006-09-21 14:59 夜沁 阅读(436) 评论(0)  编辑 收藏 引用 所属分类: c++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理