- FILE * file = fopen(s->filename, "rb");
- if (file == NULL)
- {
- Log(LOGWARN, "Couldn't open file \"%s\" mode rb - %s", s->filename, strerror(errno));
- }
- else
- {
- fseek(file, 0, SEEK_SET);
- rewind(file);
- amount_read = fread(&buffer, sizeof(DataPoint), QUERY_BUFSIZ, file);
- s->read_offset += amount_read;
- Log(LOGDEBUG, "Read %d data points; offset now at %d", amount_read, s->read_offset);
-
- fclose(file);
- }
-
+ fseek(s->file, -QUERY_BUFSIZ*sizeof(DataPoint), SEEK_END);
+ amount_read = fread(&buffer, sizeof(DataPoint), QUERY_BUFSIZ, s->file);
+ Log(LOGDEBUG, "Read %d data points", amount_read);
+