• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX:URLyBird What's magic cookie?

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my assignment there is this statement:

4 byte numeric,magic cookie value . Identifies this as a data file


What's magic cookie value?? Is it like the "cookie" in the web??
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leo,
It's just a file signature. You should check its value when you open the file to make sure the file is a data file.
Best,
Phil.
 
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Phil,
I am following up on your explanation. As far as the assignment is concerned, do we just read it from the file and forget about it? Is that what it boils down to?
Thanks.
Bharat
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bharat,
There is nothing special to do with it according to our instructions. But, as I did, you may think that "identifies this as a data file" means that if you read another value than the one expected, the file you're reading is not a datafile.
So may just skip it or throw an exception.
Best,
Phil.
 
Bharat Ruparel
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Phil,
Thanks your your response. I am following up on it. Everytime I read it I get the same value, i.e., 257 (numeric). I have no way of checking if it has been changed.
Do you mean that I should store it in a static variable on my data.java class and everytime I access the data file. I keep checking whether it has been changed? and if it is (at least in theory), then throw an exception? However, if I don't provide a mutator method in my class then it pretty much guarantees that it cannot be changed? Are you thinking of an external program inadverantly modifying this value?
Let me know your thoughts.
Thanks.
Bharat
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bharat,

Do you mean that I should store it in a static variable on my data.java class


You shouldn't but you could

and everytime I access the data file. I keep checking whether it has been changed?


Not each time you access the data file, just once when you open it.

However, if I don't provide a mutator method in my class then it pretty much guarantees that it cannot be changed? Are you thinking of an external program inadverantly modifying this value?


No, I am thinking of a user which makes a mistake (choose any wrong file) when telling your server which file is its database file.
Cheers,
Phil.
 
Popeye has his spinach. I have this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic