[Gambas-user] fastest way to "zero-out" a huge binary file

Kadaitcha Man nospam.nospam.nospam at ...626...
Sun Jan 24 06:33:23 CET 2010


On 24 January 2010 16:02, kevinfishburne
<kevinfishburne at ...1887...> wrote:

> Excellent, thanks. I seem to have found something horrifying while trying to
> create the file using GAMBAS however; using the SEEK statement with an
> argument greater than 2 GB raises a "Bad argument" error. While that doesn't
> affect my ability to create the file, it kills me later when trying to read
> and write to it. Other than using a different version of GAMBAS all I can
> think to do is to create four 2 GB data files, which will create additional
> overhead in the read/write procedures that access the file. Actually since
> my file is slightly larger than 8 GB I'll need to create five separate
> files. :(

I am using gb3 and have no problem accessing a 3.7GB file:

Stick a button on a form, then:

Private bigfile As String = Application.Path & "/bigfile"

Public Sub _new()

End

Public Sub Form_Open()

End

Public Sub Button1_Click()

  Dim hFile As File
  Dim LastChar As Byte

  hFile = Open bigfile For Input

  ' Should get 3930677248
  Debug Lof(hFile)

  Seek #hFile, 3930677241

  ' Should get 3930677241
  Debug Seek(hFile)

  Read #hFile, LastChar

  ' Should get 3
  Debug LastChar

  Close #hFile

End


Output:
FMain.Button1_Click.22: 3930677248
FMain.Button1_Click.27: 3930677241
FMain.Button1_Click.32: 3

All correct.




More information about the User mailing list