Bug 9661 – LockingTextWriter should increment file handle reference count

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-07T08:44:25Z
Last change time
2017-12-18T22:55:21Z
Assigned to
alex.jercaianu
Creator
Artem Tarasov

Comments

Comment #0 by lomereiter — 2013-03-07T08:44:25Z
Its behaviour is inconsistent with byLine() and byChunk() - which keep File struct internally instead of FILE* pointer. Compare: auto lines = File("/tmp/file.txt").byLine(); writeln(lines); // works auto writer = File("/tmp/file.txt", "w+").lockingTextWriter; writer.put("123"); // fails - the file is already closed!
Comment #1 by justin — 2014-08-13T16:14:11Z
+1 I spent an hour in frustration because of a line like this: auto buf = File("somefile", "w").lockingTextWriter(); Because the File is temporary, it immediately closes and leaves you with a LockingTextWriter with a bad handle. Since the whole point of wrapping FILE* with File is to manage its lifetime, lockingTextWriter really needs to increment and decrement the ref count.
Comment #2 by github-bugzilla — 2017-11-14T17:14:12Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/cb67c5d50f3898300e2b314f9f8695ba0fe6b850 Fix Issue 9661 - LockingTextWriter should increment file handle reference count test for locking binary writer https://github.com/dlang/phobos/commit/99002c366bfd57104e943b74cf28adea0721612d Merge pull request #5792 from jercaianu/lockingtextwriter Fix Issue 9661 - LockingTextWriter should increment file handle reference count merged-on-behalf-of: Andrei Alexandrescu <[email protected]>
Comment #3 by github-bugzilla — 2017-12-18T22:55:21Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/cb67c5d50f3898300e2b314f9f8695ba0fe6b850 Fix Issue 9661 - LockingTextWriter should increment file handle reference count https://github.com/dlang/phobos/commit/99002c366bfd57104e943b74cf28adea0721612d Merge pull request #5792 from jercaianu/lockingtextwriter