Skip to content

Commit

Permalink
Add support for HEIC
Browse files Browse the repository at this point in the history
  • Loading branch information
AJMitev committed Oct 29, 2022
1 parent a54deb6 commit 558dce2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion FileTypeChecker.Tests/FIleTypeValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{
using System;
using System.IO;
using FileTypeChecker.Abstracts;
using FileTypeChecker.Exceptions;
using FileTypeChecker.Types;
using NUnit.Framework;
Expand Down Expand Up @@ -49,6 +48,7 @@ public void IsTypeRecognizable_ShouldReturnFalseIfFormatIsUnknown()
[TestCase("365-doc.docx")]
[TestCase("testwin10.zip")]
[TestCase("test.webp")]
[TestCase("sample.heic")]
public void IsTypeRecognizable_ShouldReturnTrueIfFileIsRecognized(string filePath)
{
using var fileStream = File.OpenRead(Path.Combine(FilesPath, filePath));
Expand Down Expand Up @@ -80,6 +80,7 @@ public void IsTypeRecognizable_ShouldReturnTrueIfFileIsRecognized(string filePat
[TestCase("365-doc.docx", MicrosoftOffice365Document.TypeExtension)]
[TestCase("testwin10.zip", ZipFile.TypeExtension)]
[TestCase("test.webp", Webp.TypeExtension)]
[TestCase("sample.heic", HighEfficiencyImageFile.TypeExtension)]
public void GetFileType_ShouldReturnFileExtension(string filePath, string expectedFileExtension)
{
using var fileStream = File.OpenRead(Path.Combine(FilesPath, filePath));
Expand Down Expand Up @@ -109,6 +110,7 @@ public void GetFileType_ShouldReturnFileExtension(string filePath, string expect
[TestCase("365-doc.docx", MicrosoftOffice365Document.TypeName)]
[TestCase("testwin10.zip", ZipFile.TypeName)]
[TestCase("test.webp", Webp.TypeName)]
[TestCase("sample.heic", HighEfficiencyImageFile.TypeName)]
public void GetFileType_ShouldReturnFileName(string filePath, string expectedFileTypeName)
{
using var fileStream = File.OpenRead(Path.Combine(FilesPath, filePath));
Expand Down
3 changes: 3 additions & 0 deletions FileTypeChecker.Tests/FileTypeChecker.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<None Update="Files\blob.mp3">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="files\sample.heic">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Files\test-bom.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Binary file added FileTypeChecker.Tests/files/sample.heic
Binary file not shown.
15 changes: 15 additions & 0 deletions FileTypeChecker/Types/HighEfficiencyImageFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace FileTypeChecker.Types
{
using FileTypeChecker.Abstracts;

public class HighEfficiencyImageFile : FileType, IFileType
{
public const string TypeName = "High Efficiency Image File";
public const string TypeExtension = "heic";
private static readonly MagicSequence magicBytes = new(new byte[] { 0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63 });

public HighEfficiencyImageFile() : base(TypeName, TypeExtension, magicBytes)
{
}
}
}

0 comments on commit 558dce2

Please sign in to comment.