khwang0 / 2018F-COMP3111

19 stars 13 forks source link

[Advance 2] save and open file #21

Open Wongky opened 6 years ago

Wongky commented 6 years ago

(1) Can I disallow user to save file if no search have been performed?

(2) If the file ,which is going to be load, is not as the same format as the original saved (e.g. some price are deleted), can I restrict the user to load that file? Because it is obvious that it cannot be reconstructed as Item.

comp3111ta commented 6 years ago

1) You can. But not required. 2) I don't quite understand your question. If a file is corrupted, it will not loaded.

Wongky commented 6 years ago

@comp3111ta For example, the saved file contain: Iphone XS Max 256gb 0.0 https://newyork.craigslist.org/brk/mob/d/iphone-xs-max-256gb/6726288575.html sell ur ipad mini 4 air 2 Pro 0.0 https://newyork.craigslist.org/brk/mob/d/sell-ur-ipad-mini-4-air-2-pro/6704364340.html

but the user modified the file: Iphone XS Max 256gb 0.0 sell ur ipad mini 4 air 2 Pro 0.0 https://newyork.craigslist.org/brk/mob/d/sell-ur-ipad-mini-4-air-2-pro/6704364340.html

Therefore, the first item misses the url data and the format is not title\tprice\turl\n . Can I disallow the user to load any files that is not in the format of title\tprice\turl\n?

comp3111ta commented 6 years ago

so this is a corrupted file. Please noted that you are supposed to implement a load and save function where you can define your own format. If a user attempt to mimic the format and provide something to you, you are totally entitled not to accept it.

Put as example, if a group decided to put a digital signature or H-MAC on the file. When a user change the content and the digital signature cannot be verified, it is ok to reject it.