PLEX86  x86- Virtual Machine (VM) Program
 CVS  |  Mailing List  |  Download  |     Newsgroups    

Tidying up after Linux 16763


Your Ad Here

Your Ad Here

snips

Take a look at a Windows .EXE file in a hex editor sometime. What's the first thing you see?

Right... you see the letters "MZ". This identifies a particular type of executable file; in theory, at least, if you rename the file to something such as "file.tmp", Windows should still tell that it's an EXE file. On top of this, part of the EXE header is a checksum which, again in theory, should let a file type detector - or the application launching code - tell whether it really is a .EXE or just some random file which happens to have MZ as the first two bytes.

The same sort of idea can be applied to a hell of a lot of files, binary or otherwise. Many file types have some form of identifying tag to them.

In fact, a heck of a lot of file formats now include a "standard" 1, 2 or 4 byte magic number, usually as the first bytes of the file; this lets the application quickly tell whether it has been pbutted a bogus file or not, but it can also be used by other tools, such as "file" or a file manager, to determine the file type if needed.

Tidying up after Linux 16764
I understand this perfectly well. Just like .zip files begin with "PK, .gif files begin with "GIF87a" and so...

So, in trying to determine file types, you can start with the extension as a quick-and-dirty test. If that fails, or you want to make sure that just because something says it's a .zip, it really is, you can check the magic file number. If that fails, you can check the bangpath line, if it has one. If that fails, you could, if you were feeling energetic, run buttorted tests against it for some of the more popular file types - raw image formats and the like - which lack magic numbers.

If all that fails, you have, obviously, an unusual file to identify... but those methods account for easily 90% of the files you're ever likely to try to identify on a typical system.



Your Ad Here

Linux | Previous | Next

Tidying up after Linux 16764

Linux Advocacy from Newsgroups

The #1 Usenet Provider on the Internet

Tidying up after Linux 16762