[Issue 1583] std.cstream.CFile cannot be detached from FILE*
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 19 10:23:15 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1583
thomas-dloop at kuehne.cn changed:
What |Removed |Added
----------------------------------------------------------------------------
OS/Version|Windows |All
------- Comment #1 from thomas-dloop at kuehne.cn 2007-10-19 12:23 -------
I use the following CFileEternal class. Compile with/without -version=kludge to
see the difference.
# import std.stream : FileMode;
# import std.cstream : CFile;
# import std.c.stdio : FILE, fopen, ftell;
# import std.string : toStringz;
# import std.stdio : writefln;
#
# class CFileEternal : CFile{
# this(FILE* cfile, FileMode mode, bool seekable = false) {
# super(cfile, mode, seekable);
# }
#
# ~this(){
# flush();
# isopen = readable = writeable = seekable = false;
# }
# }
#
# void main(char[][] args){
# auto name = args[1];
# FILE* f = fopen(toStringz(name), "w");
#
# if(!f){
# throw new Exception("failed to open " ~ name);
# }
#
# {
# version(kludge){
# scope cf = new CFileEternal(f, FileMode.Out);
# }else{
# scope cf = new CFile(f, FileMode.Out);
# }
# }
#
# writefln("FILE \"%s\" has been closed: %s", name, -1 == ftell(f));
# }
--
More information about the Digitalmars-d-bugs
mailing list