neilharvey / FileSignatures

A small library for detecting the type of a file based on header signature (also known as magic number).
MIT License
250 stars 41 forks source link

allow for 0 length signatures #40

Closed markacola closed 2 years ago

markacola commented 2 years ago

I have a use case where I would like to be able to override IsMatch to validate the stream but there is no consistent file signature. It would be great if we were able to provide a zero-length header to support this use case.

neilharvey commented 2 years ago

Sure, I don't see any harm in doing this - I don't think it would break anything in an inherited class.

There is currently a broken test in your branch SignatureCannotBeNullOrEmpty but that's simply because the validation logic has changed - it's small so I'll merge the PR and remove the test.

neilharvey commented 2 years ago

I've published a new version of the library (4.2) to NuGet - give me a shout if there are any issues with it. Thanks for the PR!