zoukankan      html  css  js  c++  java
  • C语言检测对象是文件还是文件夹的代码

    把开发过程中比较常用的代码片段做个珍藏,如下的代码是关于C语言检测对象是文件还是文件夹的代码,应该能对各位朋友有用途。
    bool file_exists
    (
    )
    {
    bool Exists;
    struct stat Info;
    if (stat(Pathname, &Info) == 0)
    {
    Exists = S_ISREG(Info.st_mode);
    }
    else
    {
    Exists = false;
    return
    Exists;





    检测是否是文件夹


    bool directory_exists
    (
    bool FollowSymlink
    )
    {
    bool Exists;
    struct stat Info;
    if
    (
    (FollowSymlink ?
    stat(Pathname, &Info)
    :
    lstat(Pathname, &Info)
    )
    ==
    0
    )
    {
    Exists = S_ISDIR(Info.st_mode);
    }
    else
    {
    Exists = false;
    return
    Exists;




  • 相关阅读:
    每日日报
    每日日报
    每日日报
    每日日报
    每日日报
    动手动脑2
    动手动脑3
    每日日报
    每周总结
    Java学习
  • 原文地址:https://www.cnblogs.com/codeoldman/p/10372816.html
Copyright © 2011-2022 走看看