Any additions for write-to-file short program
pascal111
judas.the.messiah.111 at gmail.com
Fri Nov 19 22:21:52 UTC 2021
On Thursday, 18 November 2021 at 23:09:28 UTC, H. S. Teoh wrote:
> On Thu, Nov 18, 2021 at 10:20:48PM +0000, pascal111 via
> Digitalmars-d-learn wrote:
>> In next program that rewrites original written texts into new
>> files, I see that it may need some additions or we can accept
>> it like this because it's just a simple program that achieve
>> its task and doesn't need any philosophical additions.
>
> I assume there's a reason you're reading the input file by line
> instead of just copying it using larger fixed-size blocks?
> Perhaps you have in mind some kind of line-based filtering or
> processing eventually?
>
> Because for copying a file, using a large, fixed-size block
> will work much faster. Not to mention the code will be simpler.
> For example:
>
> auto inputFile = File(inputFilename, "r");
> auto outputFile = File(outputFilename, "w");
>
> enum bufferSize = 8194;
> inputFile.byChunk(bufferSize) // read input in blocks of 8194
> bytes
> .copy(outputFile.lockingBinaryWriter); // copy each block
> into output file
>
>
> T
When I compiled the code after adding yours, I found this error
message:
"untitled20.d:24:8: error: no property 'copy' for type 'ByChunk'
24 | .copy(outputFile.lockingBinaryWriter); // copy
each block into output file
| ^
"
More information about the Digitalmars-d-learn
mailing list