When someone creates a "tournament" using our standalone application, we create two files that make up that tournament - one for participants, one for brackets. We save them both as ".rev" files. This is the method we've used since 2003, and it seems to work fine.
Recently, there have been a couple of instances of these tournament files becoming corrupted, either when being sent via email, or when someone makes a "backup copy" and moves it to another machine.
The challenge this creates is the standalone built with Rev 3.0 can't proceed with a file corrupted like this, it just hangs, or worse, crashes (but the "hang" seems more common).
Opening the stack directly (not via my application) in the development environment for 3.0 produces a Rev crash. Opening the stack directly in the devlopment environment for 3.5 produces the error dialog "this file is corrupted, please check for a ~ file". These files have cleared all virus scanners successfully.
So, to the question: is there a way for me to open a file as binary, checksum it, verify that it is okay, and then either report it as corrupt or proceed? These crashes make people believe my program is misbehaving, when it _seems_ to me that it's out of my control.
Thanks in advance.
Checking a file for corruption before "loading"?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Dear rayjbenet,
There are several ways to do this. You might want to use one, some or all of them, depending on the expertise of your public/customers and the level of reliability you want to provide.
You can use the "there is a stack" syntax:
You could store a file hash somewhere and include that with the actual files on the server or send it by e-mail along with the stacks.
You could provide people with a little utility that calculates the md5 hash of a file and compares it with the hash stored in an md5 file.
Of course, you could also tell people how many bytes a file has and tell them to check the file size when they receive the file.
You might want to check that people are able to read your stack. People with older versions of Revolution need stacks to be saved in legacy format.
Best regards,
Mark
There are several ways to do this. You might want to use one, some or all of them, depending on the expertise of your public/customers and the level of reliability you want to provide.
You can use the "there is a stack" syntax:
Code: Select all
put (there is a stack "~/desktop/crash log.txt.zip") into myVar --> false
put (there is a stack "~/desktop/a real stack.rev") into myVar --> true
Code: Select all
get binarydecode("h*",md5digest(url ("binfile:~/desktop/a real stack.rev")),myHash)
put myHash into url "binfile:~/desktop/a real stack.md5"
Of course, you could also tell people how many bytes a file has and tell them to check the file size when they receive the file.
You might want to check that people are able to read your stack. People with older versions of Revolution need stacks to be saved in legacy format.
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
thanks - all good advice
Thanks for your feedback. I have already added a "Create ZIP Archive" feature that we'll recommend they use before shipping around.
Wouldn't have thought of the "there is a stack" - very clever. What you're saying is that it returns FALSE unless the item is a valid REV stack. This is exactly, I think, what I was looking for. Some easy ability to say "I'm gonna choke on this sucker - please don't make me open it."
The md5 concept I like for other applications within our domain, so am grateful for that advice as well.
Thanks!
Ray
Wouldn't have thought of the "there is a stack" - very clever. What you're saying is that it returns FALSE unless the item is a valid REV stack. This is exactly, I think, what I was looking for. Some easy ability to say "I'm gonna choke on this sucker - please don't make me open it."
The md5 concept I like for other applications within our domain, so am grateful for that advice as well.
Thanks!
Ray