This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: [BUG] fopen(..., "a") does not seek to end of file until some write operation
- From: Eric Blake <ebb9 at byu dot net>
- To: cygwin at cygwin dot com, sfandino at yahoo dot com
- Date: Fri, 13 Nov 2009 13:41:14 -0700
- Subject: Re: [BUG] fopen(..., "a") does not seek to end of file until some write operation
- References: <592384.26227.qm@web52612.mail.re2.yahoo.com>
-----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.
- --
Don't work too hard, make some time for fun as well!
Eric Blake ebb9@byu.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