[En-Nut-Discussion] fmode update
Ralph Mason
ralph.mason at telogis.com
Fri Jun 20 07:00:01 CEST 2003
I have made the following change to fmode so it gives the flags to create or
truncate a file.
I would like to submit it as part of the general code base.
Regards
Ralph
/*! \internal
* \brief Return the flags for a given mode string.
*
* \return Flags or EOF to indicate an error.
*/
int _fmode(CONST char *mode)
{
int mflags = _O_TEXT;
switch (*mode) {
case 'r':
mflags |= _O_RDONLY;
break;
case 'w':
mflags |= _O_WRONLY | _O_CREAT |_O_TRUNC ;
break;
case 'a':
mflags |= _O_APPEND | _O_CREAT;
break;
default:
errno = EINVAL;
return EOF;
}
while (*++mode) {
switch (*mode) {
case '+':
mflags &= ~(_O_RDONLY | _O_WRONLY);
mflags |= _O_RDWR;
break;
case 'b':
mflags &= ~_O_TEXT;
mflags |= _O_BINARY;
break;
default:
errno = EINVAL;
return EOF;
}
}
return mflags;
}
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.483 / Virus Database: 279 - Release Date: 19/05/2003
More information about the En-Nut-Discussion
mailing list