lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 02/05/2011 12:34, steve donovan wrote:
That's another issue: in Windows just about everything is driven by
extensions, in Unix you need something like 'file' to have a quick
peek under the hood, checking binary signatures etc.  These different
philosophies make a cross-platform solution an interesting challenge.

Well, a port of 'file' to Windows, with extension to Windows-specific files, is not impossible. Actually, I have a similar program, named TriD:

> trid ExpressionsTests.class

TrID/32 - File Identifier v2.02 - (C) 2003-06 By M.Pontello
Definitions found:  3499
Analyzing...

Collecting data from file: ExpressionsTests.class
 60.0% (.CLASS) Java Bytecode (6000/1/1)
 40.0% (.) Mac OS X Universal Binary executable (4000/1)

> trid 99BottlesOfBeer.lua

TrID/32 - File Identifier v2.02 - (C) 2003-06 By M.Pontello
Definitions found:  3499
Analyzing...

Collecting data from file: 99BottlesOfBeer.lua

Warning: file seems to be plain text/ASCII
         TrID is best suited to analyze binary files!

       Unknown!

> luac 99BottlesOfBeer.lua
> trid luac.out

TrID/32 - File Identifier v2.02 - (C) 2003-06 By M.Pontello
Definitions found:  3499
Analyzing...

Collecting data from file: luac.out
 80.0% (.OUT) Lua bytecode (generic) (4000/1)
 20.0% (.PCL) HP Printer Control Language capture/bitmap (1000/1)

Like 'file', it is based on a database of file signatures. Such program relies on heuristics, and collected data, the more user helping, the better. At least, it is able to identify an XML file (and even tell it is a SVG file) even with a random extension (XML being a domain where semi-random extensions abounds, so where Windows' method of relying on extensions often fails).

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --