2

In my C++ program I'm using ifstream("/etc/mtab", ios::ate|ios:in). An year back the program ran good but now ifstream::is_open() is returning false. By digging I found /etc/mtab is a symbolic link to /proc/mounts

--Update--

/proc/mounts is again a symbolic link to /proc/self/mounts which is actual file. I couldn't succeed opening this thought I'm running the program as a root user. So may be ifstream is following the symbolic link and is not able to open /proc/self/mounts

Necktwi
  • 2,483
  • 7
  • 39
  • 62

1 Answers1

1

although not directly answering on how to resolve symbolic links with std::fstream, a filesystem library was introduced by C++ 17 (was not available at the time this question was opened)

it can deal with symlinks by:

note that a filesystem library is also available in boost

hintze
  • 544
  • 2
  • 13