[GRASS-dev] fseeko() in libiostream

Paul Kelly paul-grass at stjohnspoint.co.uk
Tue Oct 7 05:53:08 EDT 2008


On Mon, 6 Oct 2008, Hamish wrote:

> Paul Kelly wrote:
>> I looked in r.in.xyz which only uses fseek() and
>> ISTR discussion about it handling huge files recently,
>> although perhaps that involved reading from stdin.
>
> fwiw the fseek() there is just to grab the filesize so G_percent() can
> know where 100% is. If the fseek() returns garbage no harm is done and
> G_percent() is skipped. It doesn't touch the processing aspect of the
> module, just the cosmetic user message end of things.

OK, interesting. From what I've seen then the patch below might help 
things for very large files. G_percent() still takes a long argument, so 
the number of lines can't be greater than can be represented in a long, 
but with the patch below, the actual filesize can be.

Are there any really huge files anybody can test it with?

Paul


Index: main.c
===================================================================
--- main.c      (revision 33696)
+++ main.c      (working copy)
@@ -502,7 +502,11 @@
             linesize = strlen(buff) + 1;
         }
         fseek(in_fp, 0L, SEEK_END);
+#ifdef HAVE_LARGEFILES
+       filesize = ftello(in_fp);
+#else
         filesize = ftell(in_fp);
+#endif
         rewind(in_fp);
         if (linesize < 6)       /* min possible: "0,0,0\n" */
             linesize = 6;


More information about the grass-dev mailing list