delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/11/13/15:51:08

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
Message-Id: <4AFDC6A7.60905@saic.com>
Date: Fri, 13 Nov 2009 15:50:47 -0500
From: "Roger K. Wells" <ROGER DOT K DOT WELLS AT saic DOT com>
User-Agent: Thunderbird 2.0.0.23 (X11/20090812)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: [BUG] fopen(..., "a") does not seek to end of file until some write operation
References: <592384 DOT 26227 DOT qm AT web52612 DOT mail DOT re2 DOT yahoo DOT com> <4AFDC46A DOT 3070503 AT byu DOT net>
In-Reply-To: <4AFDC46A.3070503@byu.net>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> According to Salvador Fandino on 11/13/2009 1:36 PM:
>   
>> Hii
>>
>> Using ftell() after fopen(..., "a") returns 0 even when the file open for appending is not empty. AFAIK, it should return the size of the file.
>>     
>
> Not a bug.  POSIX allows this behavior, and Linux does it as well.  POSIX
> also allows BSD behavior of seeking to the end, although this is less
> friendly to reading back a file opened with fopen(...,"a+").  So portable
> programs can't expect either situation, and you MUST use fseek when
> opening for append if you expect a particular position.
>
>   
however writing will always take place at the end of the file.
"Opening a file with append mode (a as the first character in the mode 
argument) shall cause all
subsequent writes to the file to be forced to the then current 
end-of-file, regardless of intervening
calls to fseek( )."
rw
> - --
> Don't work too hard, make some time for fun as well!
>
> Eric Blake             ebb9 AT byu DOT net
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (Cygwin)
> Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkr9xGoACgkQ84KuGfSFAYC8CACgtx1ZxOtKVaGF2xk2UHg+1B7c
> 7cUAniO/T6EOm0gxRRx/1wsCM6P2HXXl
> =xedo
> -----END PGP SIGNATURE-----
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>
>
>   


-- 
Roger Wells, P.E.
SAIC
221 Third St
Newport, RI 02840
401-847-4210 (voice)
401-849-1585 (fax)
roger DOT k DOT wells AT saic DOT com


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019