Hi,

This code to count lines in a gzipped file exits with "Program exited with code -9" when run with the latest version of the library, I guess because I am doing unsafe things. Could someone tell me how to change it to make it work? The actual program I'm writing processes a file line by line, so ideally I'd like to keep the structure of open a file, then foreach over it.

Thanks very much

Andrew

/+ dub.sdl:
        name "hello"
        dependency "iopipe" version="~>0.2.0"
+/

import std.stdio;
import std.typecons;
import iopipe.textpipe;
import iopipe.zip;
import iopipe.bufpipe;
import std.io : File = File;

void main()
{
  auto counter = 0;
auto fileToRead = File("file.gz").refCounted.bufd.unzip(CompressionFormat.gzip);

  foreach (line; fileToRead.assumeText.byLineRange!false)
  {
    counter++;
  }

  writeln(counter);
}

Reply via email to