Ooops
October 16, 2021, 00:04:59

Author Topic: 'Invalid Bank Offset' but my custom binary is still correct?  (Read 1097 times)

Offline Yellownakji

  • Sr. Member
  • ****
  • Posts: 253
  • No.
I wrote my own file format and i can ?successfully? create a binary to read from, however,  Even though i can generate a proper binary, i get a 'Invalid Bank Offset' exception.

Basically, even thought i get this error, i can still generate my binary correctly and and i don't know why it works.

--

bank = CreateBank(Size_T(StreamPos(stream))) 'Create a bank with the same size as the stream we wrote to
** I use streampos because it results the same as streamsize.  i wrote the data first so the last pos is = to the size..

ReadBank(bank, stream, Size_T(Banksize(bank)), StreamPos(stream)) 'Write the stream to the bank
SaveBank(bank, String(container)) 'Finalize the bank to a physical binary

--

Now of course, the issue may be obvious...  Arg3 in Readbank is 'Size_T(Banksize(bank))' when it should be an offset.   Okay..?

My issue is that even though this is most likely incorrect, i can still generate a perfectly working binary to read from.  Everything is in the correct order.. correct size etc etc.  My custom file's contents are just how they should be.   ....but i get an 'Invalid Bank Offset' exception?  Why does this still work?   Everything still get's written after the application terminates.

I really don't get it.    What am i supposed to do for offset?
« Last Edit: August 07, 2018, 20:51:39 by Yellownakji »

Offline col

  • Hero Member
  • *****
  • Posts: 597
Re: 'Invalid Bank Offset' but my custom binary is still correct?
« Reply #1 on: August 07, 2018, 21:07:20 »
Quote
What am i supposed to do for offset?
0 ( zero ) to start reading from the stream to the beginning of the bank?

I think you may need to reset the position pointer for the stream too as ReadBank will start to read from the current stream position for Arg4 ( count ) number of bytes. You'll need to store the size of the stream in order to do that correctly if you have already 'read' from it.

Code: [Select]
' streamsize:Size_T = Size_T(StreamPos(stream)) ' Using your method or preferably...
streamsize:Size_T = StreamSize(stream)
SeekStream(stream, 0)

bank = CreateBank(streamsize) 'Create a bank with the same size as the stream we wrote to

ReadBank(bank, stream, 0, streamsize) 'Write the stream to the bank
SaveBank(bank, String(container)) 'Finalize the bank to a physical binary
« Last Edit: August 07, 2018, 21:21:17 by col »

Offline Yellownakji

  • Sr. Member
  • ****
  • Posts: 253
  • No.
Re: 'Invalid Bank Offset' but my custom binary is still correct?
« Reply #2 on: August 07, 2018, 21:51:42 »
Thank you so much, Col!   You're such a big help, once again.

I've never worked with binary...  been itching to learn for a long time and write my own format.  Thank you!!

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal