From octave-maintainers-request at bevo dot che dot wisc dot edu Thu Nov 20 23:51:46 2003 Subject: file offsets used by fseek and ftell From: "John W. Eaton" To: octave-maintainers mailing list Date: Thu, 20 Nov 2003 23:51:44 -0600 In Matlab, fseek and ftell use integer values stored in double objects to represent file positions. In C, fseek and ftell use long. So this combination works OK (if you don't care about large files) on systems with 32-bit longs and IEEE 64-bit doubles (which can represent 52-bit integer values). But it doesn't work so well if you care about large files (the 32-bit signed value can only handle 1GB files). In Octave, we use C++ streams instead of using fseek and ftell from the C library. So we have to deal with streamoff and streampos objects, which are not guaranteed to have any conversions to integer values. So what should we do? If we introduce new streampos and streamoff types, I imagine it would be useful to have arrays of them, but I don't think we will be able to stuff these new values into double precision values reliably. I suggest a new type that works like streamoff, which will be returned from ftell. You can convert an integer value into a streamoff object, but if you have a streamoff object, you can't see what is inside it. Also, you can add, subtract, and compare streamoff objects. Having this new type would allow us to handle large files (and also build Octave with gcc 3.4, which no longer defines streampos and streamoff with simple typedefs to long). Comments or suggestions? jwe