X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=blobdiff_plain;f=src%2Fshared%2Futils.pas;h=f4b9c8971cc3c898cc45e20adbcdec80964bf043;hp=e62cc1c3fccd98571e3e6680a0216e093c452e86;hb=6b0ba68063ba1c8f35903d3e939e5eeb91d2a58c;hpb=3566fbf25b72db352365ab8c71ca440368a3caae diff --git a/src/shared/utils.pas b/src/shared/utils.pas index e62cc1c..f4b9c89 100644 --- a/src/shared/utils.pas +++ b/src/shared/utils.pas @@ -80,6 +80,9 @@ function isWadPath (const fn: AnsiString): Boolean; // adds ".wad" extension if filename doesn't have one of ".wad", ".pk3", ".zip" function addWadExtension (const fn: AnsiString): AnsiString; +// check wad signature +function isWadData (data: Pointer; len: LongWord): Boolean; + // convert number to strig with nice commas function int64ToStrComma (i: Int64): AnsiString; @@ -823,6 +826,21 @@ begin if not hasWadExtension(result) then result := result+'.wad'; end; +function isWadData (data: Pointer; len: LongWord): Boolean; + var p: PChar; +begin + p := PChar(data); + Result := + (* ZIP *) + ((len > 3) and (p[0] = 'P') and (p[1] = 'K') and (p[2] = #03) and (p[3] = #04)) or + ((len > 3) and (p[0] = 'P') and (p[1] = 'K') and (p[2] = #05) and (p[3] = #06)) or + (* PACK *) + ((len > 3) and (p[0] = 'P') and (p[1] = 'A') and (p[2] = 'C') and (p[3] = 'K')) or + ((len > 3) and (p[0] = 'S') and (p[1] = 'P') and (p[2] = 'A') and (p[3] = 'K')) or + (* DFWAD *) + ((len > 5) and (p[0] = 'D') and (p[1] = 'F') and (p[2] = 'W') and (p[3] = 'A') and (p[4] = 'D') and (p[5] = #01)) +end; + function isWadPath (const fn: AnsiString): Boolean; var