This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: EB40 Serial port #1 question.


felixwong@i-technologies.cc wrote:
> 
> Now have no problem in output part using fprintf & other file operations.
> What if I want to have a READ/WRITE device open?
> use "r+w" instead of "rw" or "wr"?

>From a linux man page:

       r      Open  text  file  for reading.  The stream is positioned at
the beginning of
              the file.

       r+     Open for reading and writing.  The stream is positioned at
the beginning  of
              the file.

       w      Truncate file to zero length or create text file for
writing.  The stream is
              positioned at the beginning of the file.

       w+     Open for reading and writing.  The file is created if  it 
does  not  exist,
              otherwise it is truncated.  The stream is positioned at the
beginning of the
              file.

       a      Open for writing.  The file is created if it does not exist. 
The stream  is
              positioned at the end of the file.

       a+     Open  for  reading  and  writing.  The file is created if it
does not exist.
              The stream is positioned at the end of the file.

       The mode string can also include the letter ``b'' either as a last
character or  as
       a  character  between  the characters in any of the two-character
strings described
       above.  This is strictly for compatibility with ANSI X3.159-1989
(``ANSI  C'')  and
       has  no  effect;  the  ``b''  is ignored on all POSIX conforming
systems, including
       Linux.  (Other systems may treat text  files  and  binary  files 
differently,  and
       adding  the ``b'' may be a good idea if you do I/O to a binary file
and expect that
       your program may be ported to non-Unix environments.)



Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]