I remember that, back in the good old days when Macs was still Macs etc., we had much fun poking the Windows people for having to rely on such crude mechanisms like file suffixes ;-)Klaus wrote:Nowadays OS X uses file suffixes to determine the filetype and
one or two OS versions later Resource forks on Mac OS will be history!
Maybe the iJail inmates will soon have to learn about the benefits of drive letters, too? ;-)))
Caution - for some strange reasons valid JPEGs on my Win machine have the "JFIF" in bytes 7 to 10!rumplestiltskin wrote:[...] check chars 5 to 8 for the presence of "jfif" [...]
Does this seem reasonable?
In Hex:
In ASCII:FF D8 FF E0 00 10 4A 46 49 46 00 [...]
(Spaces between Bytes added)ÿ Ø ÿ à · · J F I F · [...]
After playing with it a bit, I'd use such code:
Code: Select all
on mouseUp
answer file "Show me the candidate, plz!"
if it is empty then exit mouseUp
put it into myFile
open file myFile for read
read from file myFile for 42 chars
close file myFile
if ("ÿØÿà" is in it) AND ("JFIF" is in it) then
answer "It seems to be a valid JPEG!" titled "Congraz!"
else
answer "Oh my god - it's full of chars! " & CR & CR & it titled "Bummer!"
end if
end mouseUp