Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Magic Cookie

 
Wickes Potgieter
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
the start of the data file contains a magic cookie: "4 byte numeric, magic cookie value identifies this as a data file".
I noticed that the magic cookie value is 512, should we make this value a constant in our code and then validate the db file's magic cookie value with the constant value (512)? Obviously throwing an Exception stating that the file is not a valid db file if the values don't match...
Thank you,
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wickes.
Yeah that is exactly what I have done.
When I read in the DB file, I validate the file based on the magic number. If the file is invalid when I throw an Exception and report the error to the user.
Chris
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup. That's what I did too.
I think it's a good thing to do.
 
Wickes Potgieter
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic