glados-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Common.Utils.Bytecode.Header

Synopsis

Documentation

extractContentIfValidHeader :: ByteString -> IO ByteString Source #

Validates the .gla file header and returns the raw bytecode.

@details If the header is valid, drops the 10-byte header and returns the code. If invalid, prints a generic error and exits.

evaluateHeader :: ByteString -> Bool Source #

Evaluates the header validity by combining all predicates.

@details Uses short-circuit boolean logic (&&). Order matters: hasValidSize must be checked first to prevent segmentation faults in hasValidVersion.

hasValidSize :: ByteString -> Bool Source #

Checks if the file is large enough to contain a header (10 bytes).

hasValidMagic :: ByteString -> Bool Source #

Checks if the Magic Number is GLAD (0x47 0x4C 0x41 0x44).

hasValidVersion :: ByteString -> Bool Source #

Checks if the Version is supported (0x02).