What guarantee do I have after is_regular_file?

Viewed 606

Considering a boost::filesystem::path p, is it possible to have boost::filesystem::is_regular_file(p) == true and std::ifstream(p.c_str()).is_open() == false in the same time? If yes, in which kind of situation?

The context is the writing of an assert for a comparison function:

bool identical_files(const boost::filesystem::path& p1, const boost::filesystem::path& p2)
{
  assert(boost::filesystem::is_regular_file(p1));
  assert(boost::filesystem::is_regular_file(p2));
  std::ifstream f1(p1.c_str());
  assert(f1.is_open()); // IS THIS REDUNDANT ???
  std::ifstream f2(p2.c_str());
  assert(f2.is_open());
  // ...
  // ...
  // ...
}
1 Answers
Related