Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Strange Behaviour in finding Size of a File |
| Date | 2012-11-13 07:27 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <k7tebd$fur$1@dont-email.me> (permalink) |
| References | <8439d649-fae9-4828-8a86-d0c7c8489aa5@googlegroups.com> <k7ir1b$oie$1@dont-email.me> <bcef37b1-fd1f-4b00-9b6a-173c090fdc4c@googlegroups.com> |
On 11/13/2012 01:23 AM, felix wrote: > On Friday, 9 November 2012 17:26:28 UTC+5:30, James Kuyper wrote: ... > As said above, the file I/O is buffered. The file size was not > getting updated after each fwrite(). We tried to fflush() the after > writing the data into log files. And now we see the correct size of > the file. Note: the size that you saw before was also the correct size. That is - it was the actual size currently taken up by the file on disk. It didn't include the part that was still in the buffers, and had not yet been written to the disk (that explanation is somewhat incomplete, but it's good enough for this context). That might not have been the quantity you wanted to know, but that doesn't make it incorrect. > We are trying to understand ftell()/fseek() also as suggested. If fflush() caused stat() to give you the size that you wanted, calling ftell() is almost certainly a more efficient way of getting that size information - at least if you can call it from within the same program that's writing to the log file. According to the C standard, this is only guaranteed if the file is opened in binary mode, but your use of stat() suggests that you may be using a Unix-like system, in which case text mode is indistinguishable from binary mode. Your wording implies that you're having trouble understand ftell(). Can you explain the nature of your confusion? -- James Kuyper
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Strange Behaviour in finding Size of a File felix <ckpradip@gmail.com> - 2012-11-08 23:09 -0800
Re: Strange Behaviour in finding Size of a File "Where's all the China Blue food?" <chine.bleu@yahoo.com> - 2012-11-08 23:26 -0800
Re: Strange Behaviour in finding Size of a File James Kuyper <jameskuyper@verizon.net> - 2012-11-09 06:56 -0500
Re: Strange Behaviour in finding Size of a File felix <ckpradip@gmail.com> - 2012-11-12 22:23 -0800
Re: Strange Behaviour in finding Size of a File James Kuyper <jameskuyper@verizon.net> - 2012-11-13 07:27 -0500
Re: Strange Behaviour in finding Size of a File felix <ckpradip@gmail.com> - 2012-11-19 01:52 -0800
Re: Strange Behaviour in finding Size of a File James Kuyper <jameskuyper@verizon.net> - 2012-11-19 08:09 -0500
Re: Strange Behaviour in finding Size of a File Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-11-09 08:24 -0500
Re: Strange Behaviour in finding Size of a File Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-11-10 06:06 -0800
Re: Strange Behaviour in finding Size of a File Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-11-10 15:12 +0000
Re: Strange Behaviour in finding Size of a File Ian Collins <ian-news@hotmail.com> - 2012-11-11 08:40 +1300
Re: Strange Behaviour in finding Size of a File Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-11-10 20:36 +0000
Re: Strange Behaviour in finding Size of a File Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-11-10 10:13 -0500
Re: Strange Behaviour in finding Size of a File John Gordon <gordon@panix.com> - 2012-11-09 15:16 +0000
Re: Strange Behaviour in finding Size of a File Mark Bluemel <mark_bluemel@pobox.com> - 2012-11-09 15:56 +0000
Re: Strange Behaviour in finding Size of a File James Kuyper <jameskuyper@verizon.net> - 2012-11-09 11:01 -0500
Re: Strange Behaviour in finding Size of a File Greg Martin <greg@softsprocket.com> - 2012-11-09 08:59 -0800
Re: Strange Behaviour in finding Size of a File Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-11-09 19:42 +0100
Re: Strange Behaviour in finding Size of a File Keith Thompson <kst-u@mib.org> - 2012-11-09 11:29 -0800
Re: Strange Behaviour in finding Size of a File Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-11-09 20:47 +0100
Re: Strange Behaviour in finding Size of a File Keith Thompson <kst-u@mib.org> - 2012-11-09 12:33 -0800
Re: Strange Behaviour in finding Size of a File Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-11-10 02:08 +0100
Re: Strange Behaviour in finding Size of a File Philip Lantz <prl@canterey.us> - 2012-11-09 18:33 -0800
Re: Strange Behaviour in finding Size of a File gazelle@shell.xmission.com (Kenny McCormack) - 2012-11-10 02:58 +0000
Re: Strange Behaviour in finding Size of a File Philip Lantz <prl@canterey.us> - 2012-11-09 23:29 -0800
Re: Strange Behaviour in finding Size of a File Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-11-10 06:09 -0800
Re: Strange Behaviour in finding Size of a File Ian Collins <ian-news@hotmail.com> - 2012-11-10 17:46 +1300
Re: Strange Behaviour in finding Size of a File James Kuyper <jameskuyper@verizon.net> - 2012-11-10 22:20 -0500
Re: Strange Behaviour in finding Size of a File Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-11-12 14:01 +0200
Re: Strange Behaviour in finding Size of a File gazelle@shell.xmission.com (Kenny McCormack) - 2012-11-10 22:01 +0000
Re: Strange Behaviour in finding Size of a File James Kuyper <jameskuyper@verizon.net> - 2012-11-09 22:14 -0500
Re: Strange Behaviour in finding Size of a File Keith Thompson <kst-u@mib.org> - 2012-11-09 19:24 -0800
Re: Strange Behaviour in finding Size of a File James Kuyper <jameskuyper@verizon.net> - 2012-11-09 23:30 -0500
Re: Strange Behaviour in finding Size of a File Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-11-10 08:32 -0500
Re: Strange Behaviour in finding Size of a File Ike Naar <ike@sverige.freeshell.org> - 2012-11-10 17:42 +0000
Re: Strange Behaviour in finding Size of a File Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-11-10 15:19 -0500
Re: Strange Behaviour in finding Size of a File Keith Thompson <kst-u@mib.org> - 2012-11-09 11:34 -0800
csiph-web