--==[[############################################################]]==-- --==[[ Function Name: IsHeader; ]]==-- --==[[ Function Desc: Checks if a certain file contains a header ]]==-- --==[[ using the given table of bytes. even null ]]==-- --==[[ character is supported! ]]==-- --==[[ Author: Imagine Programming ]]==-- --==[[ Website: http://www.imagine-programming.com ]]==-- --==[[ ]]==-- --==[[ Returns -1 if byte table is corrupt (numbers between 0 ]]==-- --==[[ and 255 required.. ]]==-- --==[[ Returns -2 if file couldn't be read. ]]==-- --==[[ Returns -3 if byte table has no entries. ]]==-- --==[[ Returns true if header was found. ]]==-- --==[[ Returns false if header was not found. ]]==-- --==[[############################################################]]==-- function IsHeader(sFile, tBytes) local sBytes; if(tBytes)then sBytes = ""; for i, v in pairs(tBytes) do if(type(v=="number"))and(v<256)and(v>-1)then sBytes=sBytes..string.char(v); else return -1; end end local f = io.open(sFile, "rb"); if(f)then local nBytesLength = string.len(sBytes); if(nBytesLength~=0)then local c = f:read(nBytesLength); f:close(); if(c==sBytes)then return true; else return false; end else f:close(); return -3; end else return -2; end end end