X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Message-ID: <4AFE1399.9040500@gmail.com> Date: Sat, 14 Nov 2009 02:19:05 +0000 From: Dave Korn User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) 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> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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: > According to Salvador Fandino on 11/13/2009 1:36 PM: >> 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. I'm really confused; aren't you saying that there is exactly no difference between opening for append and just opening in ordinary r/w mode? I always thought the positioning of the write pointer immediately after open was the only possible difference there could be. cheers, DaveK -- 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