Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: position in file when saving |
| Date | 2016-03-25 11:07 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <87oaa295o7.fsf@bsb.me.uk> (permalink) |
| References | (7 earlier) <b1c65b9d-879e-4ac2-b7f4-1624171fce73@googlegroups.com> <lnbn635y50.fsf@kst-u.example.com> <nd20jc$qvd$1@jstuckle.eternal-september.org> <87twjv8ha9.fsf@bsb.me.uk> <nd29r5$gt1$1@jstuckle.eternal-september.org> |
Jerry Stuckle <jstucklex@attglobal.net> writes: > On 3/24/2016 9:42 PM, Ben Bacarisse wrote: >> Jerry Stuckle <jstucklex@attglobal.net> writes: >> >>> On 3/24/2016 6:06 PM, Keith Thompson wrote: >>>> supercat@casperkitty.com writes: >>>>> On Thursday, March 24, 2016 at 2:57:28 PM UTC-5, Keith Thompson wrote: >>>>>> supercat writes: >>>>>>> Is there any requirement that the previous call to ftell() must >>>>>>> have been performed within the current execution of the program? >>>>>>> Also, by what means if any could a current-position-relative >>>>>>> fseek() ever have meaningfully- defined behavior? >>>>>> >>>>>> Have you checked N1570 7.21.9.2? >>>>> >>>>> I should have omitted the follow-on question, but I think the first is >>>>> valid and the cited section doesn't mention it. The possibility that the >>>>> call may have been made on a previous execution of the program isn't >>>>> merely a theoretical exercise. Some implementations of "fortune" have >>>>> an index file that contains the offset to the start of each entry in the >>>>> main text file; is such an approach guaranteed to work? >>>> >>>> It says "a value returned by an earlier successful call to the ftell >>>> function on a stream associated with the same file". If it said "the >>>> same stream", I'd say it has to be within the current execution, but a >>>> *file* can persist across multiple executions, or even executions of >>>> different programs. (That's pretty much what files are for, after all.) >>>> >>>> My interpretation is that it can use a saved position from a previous >>>> execution. (Unless of course the file has changed, but the committee >>>> left that can of worms closed, or at least indeterminate.) >>> >>> When the program ends, all streams are closed. >> >> That's not universally true. Open files are not guaranteed to be closed >> when the program ends (see, for example, the abort function). >> > > And when abort is called, the OS is responsible for cleaning up > resources - including streams and memory. You are mixing up two things -- closing the file and cleaning up resources. For example, in C, closing an output file flushes any pending output. C gives an implementation permission to "not close all files" on abort because it does not want to force all implementations to have to do that flushing in all cases. It also helps to be clear about what usually happens and what must happen according to the language standard. An implementation is permitted to close all open files (in the C sense, that is) on abort -- it's just not obliged to. <snip> >>> There is no previous >>> stream to be associated with the same file. >> >> But the text refers to a previous "value returned by an earlier >> successful call to the ftell function on a stream associated with the >> same file". All that is needed is that there be a stream (a new one as >> you say) associated with the old file. It doesn't matter that the >> stream once used to get the ftell value is no longer around. >> > > A new stream starts at the beginning or end of the file, depending on > how it was opened (read/write/append). And if the stream is no longer > around, neither is any residual information on the location of the > stream when it was closed. That's all freed up also. I think you've just lost track of what the question was. It is this: if a program fseeks an open file and records the value returned by ftell in some permanent way (maybe in some other file), can a second program open that file, read the saved value and use it in a fseek call? <snip> -- Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
position in file when saving fir <profesor.fir@gmail.com> - 2016-03-24 08:29 -0700
Re: position in file when saving Barry Schwarz <schwarzb@dqel.com> - 2016-03-24 10:11 -0700
Re: position in file when saving fir <profesor.fir@gmail.com> - 2016-03-24 10:51 -0700
Re: position in file when saving Robert Wessel <robertwessel2@yahoo.com> - 2016-03-24 13:07 -0500
Re: position in file when saving Stephen Sprunk <stephen@sprunk.org> - 2016-03-24 14:22 -0500
Re: position in file when saving supercat@casperkitty.com - 2016-03-24 12:40 -0700
Re: position in file when saving Keith Thompson <kst-u@mib.org> - 2016-03-24 12:57 -0700
Re: position in file when saving supercat@casperkitty.com - 2016-03-24 13:15 -0700
Re: position in file when saving Keith Thompson <kst-u@mib.org> - 2016-03-24 15:06 -0700
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-24 20:29 -0400
Re: position in file when saving Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-03-25 01:42 +0000
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-24 23:07 -0400
Re: position in file when saving Ian Collins <ian-news@hotmail.com> - 2016-03-25 16:21 +1300
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-25 09:00 -0400
Re: position in file when saving Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-03-25 11:07 +0000
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-25 09:06 -0400
Re: position in file when saving Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-03-25 14:22 +0000
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-25 10:57 -0400
Re: position in file when saving Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-03-25 16:31 +0000
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-25 12:36 -0400
Re: position in file when saving luser droog <luser.droog@gmail.com> - 2016-03-25 09:49 -0700
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-25 13:00 -0400
Re: position in file when saving Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-03-25 20:35 +0000
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-25 16:59 -0400
Re: position in file when saving Ian Collins <ian-news@hotmail.com> - 2016-03-26 10:46 +1300
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-25 20:22 -0400
Re: position in file when saving Ian Collins <ian-news@hotmail.com> - 2016-03-26 13:42 +1300
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-26 09:17 -0400
Re: position in file when saving supercat@casperkitty.com - 2016-03-26 07:50 -0700
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-26 21:37 -0400
Re: position in file when saving supercat@casperkitty.com - 2016-03-27 08:14 -0700
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-27 12:45 -0400
Re: position in file when saving supercat@casperkitty.com - 2016-03-27 12:20 -0700
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-27 17:07 -0400
Re: position in file when saving supercat@casperkitty.com - 2016-03-27 14:15 -0700
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-27 17:26 -0400
Re: position in file when saving Ken Brody <kenbrody@spamcop.net> - 2016-03-28 10:36 -0400
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-28 11:01 -0400
Re: position in file when saving David Brown <david.brown@hesbynett.no> - 2016-03-29 10:18 +0200
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-29 09:02 -0400
Re: position in file when saving Ian Collins <ian-news@hotmail.com> - 2016-03-30 08:24 +1300
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-29 15:57 -0400
Re: position in file when saving Ian Collins <ian-news@hotmail.com> - 2016-03-30 09:04 +1300
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-29 16:22 -0400
Re: position in file when saving Ian Collins <ian-news@hotmail.com> - 2016-03-31 17:31 +1300
Re: position in file when saving gazelle@shell.xmission.com (Kenny McCormack) - 2016-03-31 09:55 +0000
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-31 10:01 -0400
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-29 16:31 -0400
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-30 17:27 -0400
Re: position in file when saving Ian Collins <ian-news@hotmail.com> - 2016-03-31 16:19 +1300
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-31 10:06 -0400
Re: position in file when saving Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-03-29 05:21 -0700
Re: position in file when saving Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-29 09:05 -0400
Re: position in file when saving Ken Brody <kenbrody@spamcop.net> - 2016-03-25 14:33 -0400
Re: position in file when saving Keith Thompson <kst-u@mib.org> - 2016-03-25 11:38 -0700
Re: position in file when saving supercat@casperkitty.com - 2016-03-25 14:05 -0700
Re: position in file when saving Nick Bowler <nbowler@draconx.ca> - 2016-03-28 16:14 +0000
Re: position in file when saving Tim Rentsch <txr@alumni.caltech.edu> - 2016-03-30 09:31 -0700
Re: position in file when saving Ian Collins <ian-news@hotmail.com> - 2016-03-25 15:06 +1300
Re: position in file when saving Ian Collins <ian-news@hotmail.com> - 2016-03-25 15:00 +1300
Re: position in file when saving Les Cargill <lcargill99@comcast.com> - 2016-03-24 22:15 -0500
csiph-web