Differentiate between a unix directory and file in C and C++

后端 未结 4 1145

Given a path, say, /home/shree/path/def, I would want to determine if def is a directory or a file. Is there a way of achieving this in C or C++ code?

4条回答
  •  生来不讨喜
    2020-12-05 11:29

    What about using the boost::filesystem library and its is_directory(const Path& p) ? It may take a while to get familiar with, but not so much. It probably worths the investment, and your code will not be platform specific.

提交回复
热议问题