AJMitev / FileTypeChecker

Cross platform file type validator for .NET
MIT License
139 stars 27 forks source link

Added dynamically assessed MinimalBufferSize to allow validation with custom validators requiring more than 20 bytes #33

Closed ziocampo closed 7 months ago

ziocampo commented 7 months ago

Hello @AJMitev

I'm using your library in many projects with custom validators.

In a particular case I have to validate / recognize a couple of CSV files and I would like to stick to the "Use FileTypeChecker" pattern. The problem with this approach is that the BufferDefaultSize is fixed to 20 bytes, which in many cases is below the threshold I need to accurately determine the file type.

So I modified it to be dynamically determined, based on the size of the largest MagicSequence defined for the FileType being checked. Since BufferDefaultSize wasn't a fitting name anymore I renamed it to BufferSize, making it a getter.

I also added an appropriate test (GetFileType_ShouldUseTheMinimalBufferSizeWhenUsingStream).

Thank you very much for your time and effort, best regards

Daniele (ziocampo)

ziocampo commented 7 months ago

Could you please release the package?

AJMitev commented 7 months ago

Hello, @ziocampo, first thank you for your kind words and for your contribution to this project I really appreciate it! I am planning release it this weekend.

ziocampo commented 7 months ago

Thank you.