Talk:Append a record to the end of a text file: Difference between revisions

From Rosetta Code
Content added Content deleted
m (add missing signature)
(Improvement needed/notes on append portability)
Line 2: Line 2:
Basically I was looking for an example of appending an actual record to a file and found no such task.
Basically I was looking for an example of appending an actual record to a file and found no such task.
<div><small>''(This was written by [[User:NevilleDNZ|NevilleDNZ]] ([[User_talk:NevilleDNZ|Talk]] | [[Special:Contributions/NevilleDNZ|contribs]]) at 10:59, 12 September 2011)''</small></div>
<div><small>''(This was written by [[User:NevilleDNZ|NevilleDNZ]] ([[User_talk:NevilleDNZ|Talk]] | [[Special:Contributions/NevilleDNZ|contribs]]) at 10:59, 12 September 2011)''</small></div>

: Still needs some work IMO; it's got lots of small bits and pieces jumbled together without quite a coherent story. It's probably not that hard to improve it to the point of being good though.
: And as a side note, POSIX systems have the O_APPEND flag to the open() syscall which makes this trivial (if it is exposed by the language) provided appropriate flushing is used. (Even better, the flag is inheritable by subprocesses; that's a ''very'' useful thing at times.) By contrast, on Windows you need to lock the file to do this safely and that's error prone and much more complex in practice. Moreover, locks aren't inheritable (of course). Damn, but I wish the folks at Redmond actually ''understood all'' of POSIX properly, as it has some really wonderful things in there. –[[User:Dkf|Donal Fellows]] 13:58, 12 September 2011 (UTC)

Revision as of 13:58, 12 September 2011

Rationale

Basically I was looking for an example of appending an actual record to a file and found no such task.

(This was written by NevilleDNZ (Talk | contribs) at 10:59, 12 September 2011)
Still needs some work IMO; it's got lots of small bits and pieces jumbled together without quite a coherent story. It's probably not that hard to improve it to the point of being good though.
And as a side note, POSIX systems have the O_APPEND flag to the open() syscall which makes this trivial (if it is exposed by the language) provided appropriate flushing is used. (Even better, the flag is inheritable by subprocesses; that's a very useful thing at times.) By contrast, on Windows you need to lock the file to do this safely and that's error prone and much more complex in practice. Moreover, locks aren't inheritable (of course). Damn, but I wish the folks at Redmond actually understood all of POSIX properly, as it has some really wonderful things in there. –Donal Fellows 13:58, 12 September 2011 (UTC)