On 1/15/07, Dennis Birch <[EMAIL PROTECTED]> wrote:
On 1/15/07, Arnaud Nicolet <[EMAIL PROTECTED]> wrote: > Le 16 janv. 07 à 01:48 Matin, Dennis Birch a écrit: > > > On 1/15/07, Louis G5 Batayte <[EMAIL PROTECTED]> wrote: > >> > >> MacOS X 10.4.8 RB 2007R1 > >> > >> I let the user select a folder, then I search through the items in > >> that folder looking for jpeg files. Right now I am looking at the > >> extension to determine if it is a jpeg or not. But I am trying to > >> determine if a file without an extension is a jpeg file. If I take a > >> jpeg file with an extension, and use the MacOS System "Get Info" to > >> delete the extension, the System "Get Info" still displays the "Kind" > > >> as a jpeg file. But I cannot figure how to determine this from > >> within RealBasic. When I look at the contents of the folderitem, for > >> the file without the jpeg extension, in debug mode, there is > >> nothing there to indicate the file type/kind. Any suggestions? > > > > > >> From looking at a handful of JPEG files in a hex editor, it > >> appears that the > > first 10 bytes of every JPEG file is identical: ff d8 ff e0 00 10 > > 4a 46 49 > > 46. So you might consider opening each file, or each questionable file > > perhaps, and reading the first 10 bytes of its binarystream to see > > if it > > matches that pattern. > > What about if I create an application which writes files with the > same pattern? > I mean: is reading bytes of a file a reliable way to determine it's > contents? I suspect that those 10 bytes (and possibly more) are a standard file header for JPEG files. I also suspect it should be possible to confirm or disprove that pretty easily with a simple Web search. If that is a standard file header, then it seems to me it would be a safe method of determining a file's type. On the other hand, you raise a good point in that there's nothing to prevent somebody from writing a non-JPEG file with those 10 bytes at the beginning.
I just did a search for "jpeg file header" and here's a nice reference I found: <http://www.obrador.com/essentialjpeg/headerinfo.htm> _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
