Re: Migrating VC6.0 -> Visual Studion 2008 - depricated functions
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Wed, 11 Nov 2009 12:17:38 -0500
Interesting. I had not actually noticed that. But now there's a serious problem: suppose
I WANT to open the file with _SH_DENYNO. For example, if I want to open it in sharable
mode and I want to specify the encoding used. I note that _fsopen/_wfsopen/_tfsopen do
not appear to allow the ccs=encoding option. So instead of giving me complete control, I
only get a subset of the specifications in one (fopen_s) and a different, exlusive, subset
of specifications in another. But there appears to be no way to open a file in the C
library if I need to specify both sharing and encoding.
Unless, of course, _fsopen and _wfsopen allow me to specify the encoding, but neglected to
document it. I'm a bit busy today, and don't want to look it up, but I'm adding it as a
project to look into for my "errors and omissions" document.
[Side note: the MASM documentation in the MSDN has to be among the worst documentation I
have ever seen; it doesn't even give basic identifier syntax, uses some constructs whose
syntax is never even described ("initializer") and makes reference to pieces of syntax ("a
constant starting with %") that are never, ever explained anywhere else. I'm slowly
adding these to my list as I develop a course in assembly code programming]
Note that I hardly ever use the raw C library; I tend to use CStdioFile::Open to get file
objects for simple text I/O, which does allow me to set all the state I want.
joe
On Wed, 11 Nov 2009 02:41:55 -0600, Scot Brennecke <ScotB@xxxxxxxxxxxxxxxxxx> wrote:
Joseph M. Newcomer wrote:Joseph M. Newcomer [MVP]
I find the fopen_s a truly weird mechanism, since there was nothing that could cause a
"buffer overflow" in fopen.
Well, the "_s" is for "safe", not necessarily "safe from buffer
overflows". In the case of fopen_s, the sharing mode defaults to
_SH_SECURE instead of _SH_DENYNO. Also, the use of a FILE** parameter
instead of a FILE * return code might make it slightly harder for people
to do something stupid and dangerous with the return value.
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Migrating VC6.0 -> Visual Studion 2008 - depricated functions
- From: Uwe Kotyczka
- Re: Migrating VC6.0 -> Visual Studion 2008 - depricated functions
- From: Joseph M . Newcomer
- Re: Migrating VC6.0 -> Visual Studion 2008 - depricated functions
- From: Scot Brennecke
- Migrating VC6.0 -> Visual Studion 2008 - depricated functions
- Prev by Date: Re: VC 6 to VC 9 conversion Linker Issue
- Next by Date: Re: Efficient way to synchronize bool variables
- Previous by thread: Re: Migrating VC6.0 -> Visual Studion 2008 - depricated functions
- Next by thread: Re: Migrating VC6.0 -> Visual Studion 2008 - depricated functions
- Index(es):
Relevant Pages
|