|
-
December 13th, 2002, 01:02 PM
#1
Opening Files
Hello,
Is there a way to see why a file didn't open using the ofstream class? In C, you can check the errno and it will tell you why it didn't open (i.e. wrong permissions, file didn't exist, etc...). Is this possible with ofstream?
Thanks,
-d
-
December 14th, 2002, 01:24 AM
#2
-
December 14th, 2002, 05:11 AM
#3
You can always use GetLastError() (or something similar to figure out the last error).
Anyway, ofstream: pen documentation says:
"Opens a disk file and attaches it to the stream’s filebuf object. If the filebuf object is already attached to an open file, or if a filebuf call fails, the ios::failbit is set. If the file is not found, the ios::failbit is set only if the ios::nocreate mode was used."
Other way is to call ofstream::is_open:
"Returns a nonzero value if this stream is attached to an open disk file identified by a file descriptor; otherwise 0."
Dan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|