Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
add - Added version information
Browse files Browse the repository at this point in the history
---

You can now query the libmagic version using the MagicHandler.MagicVersionId property.

---

Type: add
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Mar 25, 2024
1 parent 3dd8d6c commit a654f84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions FileMagic.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ static int Main(string[] args)
// Now, analyze the file!
try
{
TextWriterColor.WriteColor($"libmagic version {MagicHandler.MagicVersionId}", ConsoleColors.Green);
string[] magicPaths = MagicHandler.GetMagicPaths(customMagic);
TextWriterColor.WriteColor("Magic paths:", ConsoleColors.White);
ListWriterColor.WriteList(magicPaths, false);
Expand Down
6 changes: 6 additions & 0 deletions FileMagic.Native/Interop/MagicHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ internal static unsafe class MagicHelper
[DllImport("libmagic")]
public static extern int magic_getparam(MagicSet* ms, MagicParameters param, IntPtr val);

/// <summary>
/// int magic_version(void)
/// </summary>
[DllImport("libmagic")]
public static extern int magic_version();

internal static string GetError(MagicSet* handle)
{
var errorHandle = magic_error(handle);
Expand Down
6 changes: 6 additions & 0 deletions FileMagic/MagicHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public static class MagicHandler
private const string magicFileName = "magic.mgc";
private static readonly string magicPathDefault = Path.GetFullPath(magicFileName);

/// <summary>
/// libmagic version identification number
/// </summary>
public static int MagicVersionId =>
MagicHelper.magic_version();

/// <summary>
/// Gets the file magic paths
/// </summary>
Expand Down

0 comments on commit a654f84

Please sign in to comment.