Search code examples
c++boostboost-filesystem

Difference between is_regular and is_regular_file from boost filesystem


I see here boost::filesystem::is_regular is guarded by BOOST_FILESYSTEM_NO_DEPRECATED, so I assume it shouldn't be used anymore.

I tested both methods on files and they seem to give the same result, but given that I can't find anywhere the documentation of these methods, what is the actual difference between boost::filesystem::is_regular and boost::filesystem::is_regular_file? Are they the same thing or the former is more generic (e.g.: regular symlink, etc.)?


Solution

  • They are identical:

    inline bool is_regular_file(file_status f) BOOST_NOEXCEPT {
      return f.type() == regular_file;
    }
    
    inline bool is_regular(file_status f) BOOST_NOEXCEPT {
      return f.type() == regular_file;
    }
    

    Sources:

    I suspect that is_regular() was deprecated when the Filesystem TS decided to call that function is_regular_file() instead.