G
Grumble
Hello all,
According to P.J. Plauger's C++ library reference,
std::ifstream ifs(filename);
will initialize several objects, then call
sb.open(filename, ios_base::in);
which calls cstdio's fopen().
As far as I understand, fopen() can fail for many different reasons:
EINVAL or any of the errors specified for open() i.e. EEXIST, EISDIR,
EACCES, ENAMETOOLONG, ENOENT, ENOTDIR, ENXIO, ENODEV, EROFS, ETXTBSY,
EFAULT, ELOOP, ENOSPC, ENOMEM, EMFILE, ENFILE (if my documentation is
correct) or any of the errors specified for malloc().
If I understand correctly, I can test for failure with
if (ifs == NULL) handle_error();
How can I tell the user precisely why I couldn't open his file?
Is errno saved somewhere inside the file stream object?
(Perhaps I should have asked in comp.unix.programmer? I'm not sure.)
According to P.J. Plauger's C++ library reference,
std::ifstream ifs(filename);
will initialize several objects, then call
sb.open(filename, ios_base::in);
which calls cstdio's fopen().
As far as I understand, fopen() can fail for many different reasons:
EINVAL or any of the errors specified for open() i.e. EEXIST, EISDIR,
EACCES, ENAMETOOLONG, ENOENT, ENOTDIR, ENXIO, ENODEV, EROFS, ETXTBSY,
EFAULT, ELOOP, ENOSPC, ENOMEM, EMFILE, ENFILE (if my documentation is
correct) or any of the errors specified for malloc().
If I understand correctly, I can test for failure with
if (ifs == NULL) handle_error();
How can I tell the user precisely why I couldn't open his file?
Is errno saved somewhere inside the file stream object?
(Perhaps I should have asked in comp.unix.programmer? I'm not sure.)