How do I clear a file in D?

In D, I write to a file:

File opfile = File(opdir~opname, "w");
... //first gap
opfile.writeln("somestuff");
... //second gap
opfile.writeln("otherstuff");

      

In this case, the stuff in the first space takes a few minutes and the stuff in the second space takes several hours, and I would like to see "somestuff" written to the file before the end of the program as a sanity check.

It looks to me like D is using buffered output, and hence all output is written right after the second space. In C ++, I used ostream :: flush to manually flush the file before the second break.

What is the equivalent operation in D? I cannot find it in the documentation for std.file.

+3


source to share


1 answer


Cm. opfile.flush()



Calls fflush on the file descriptor.

+6


source







All Articles