Poll
Question:
How to deal with large files?
Option 1: optional argument(s)
votes: 1
Option 2: new functions (EX)
votes: 1
Option 3: new functions (size below 1Gig, size above 1 Gig)
votes: 2
Option 4: We want 64 bit integers!
votes: 9
Option 5: Dave Perry
votes: 0
Hi,
GETFILESIZE returns a signed 32 bit integer. That means, file sizes > 2GB will appear negative, and file sizes > 4 GB are cut off.
How should I deal with this? (I have a project where that matters, actually).
1. GETFILESIZE(f$, BYREF nof_gigabytes_to_add% = null)
2. GETFILESIZEEX(f$, BYREF bytes%, BYREF gigabytes%)
3. GETFILESIZE(f$); GETFILESIZEGIGS(f$)
Before you vote, keep in mind that next time someone wants to have FILESEEK and FILEPOS with large files, too...
With option 3 (and 2 perhaps), you would need a command maybe 'ISFILESIZEGT2GB()' or something so you know which method to use.
I like option 1, with an optional BYREF GB counter, for when you may be working with large files. Its just that if you don't check that gb count, your code may not work for larger files, but hey, it doesn't work now so no problem.
Something like this?:
LOCAL fileBytes%
LOCAL fileGBytes%
fileBytes = GETFILESIZE("test.dat", fileGBytes)
DEBUG "File Size: " + (fileGBytes * 1024 * 1024 * 1024) + fileBytes
// Except of course this will STILL overflow, just trying to illustrate its usage
[Edit] Ha, or offer a new 8 byte integer data type!
Best is if qword type was supported as glbasic, which is 8 bytes long....
Is a 64bit integer type even an option? Well if not I kinda like the 2nd parameters option.
The ideal scenario would be 8-byte integers being automatically used in systems that support them.
OK, I reset the poll-counter and added the "8 bit integer" option.
How would you declare such a thing?
LOCAL size as INT64 ?
INT64 sound good to me! :good:
BTW shouldn't the survey now say "8 byte integers"?
Why not update the current commands to be able to deal with large sizes ?
So change GETFILESIZE to handle 64 (or even 128 :) ) bit integers, and update the other commands accordingly...
we want 8 bit integers? do you mean 8 bytes integers? hehe.
INT64 sound nice for me.
I vote for using extended functions. This Ex function can handle 8 byte integers. Then the existing code works and when you want to support you use Ex() functions and get the result in a larger type.