2 private LineParser parser;
3 private Cancellable cancellable;
5 public IMDbGzipParser (Cancellable? _cancellable) {
6 cancellable = _cancellable;
9 public void parse (string path, LineParser? _parser) throws IOError {
12 var file = File.new_for_path (path);
13 var info = file.query_info (FILE_ATTRIBUTE_STANDARD_SIZE, FileQueryInfoFlags.NONE, cancellable);
14 int total = (int) info.get_size ();
15 var gz_stream = new GzipInputStream (file.read (cancellable));
16 var stream = new DataInputStream (gz_stream);
22 line = stream.read_line (out length, cancellable);
23 while (line != null) {
24 parser.parse_line (line);
25 line = stream.read_line (out length, cancellable);
26 if (gz_stream.total_in () > total_in) {
27 total_in = (int) gz_stream.total_in ();
28 progress (total, total_in);
33 public signal void progress (int total, int now);