/// <summary> /// Can be used to check the validity of entries /// in the colon separated database files /// </summary> /// <param name="dbPath"></param> public void CheckDatabase(string dbPath = null) { ThrowIfDisposed(); if (dbPath == null) { dbPath = MagicUtils.GetDefaultMagicPath(); } int result = MagicNative.magic_check(_magic, dbPath); if (result < 0) { throw new MagicException(LastError); } }
public Magic(MagicOpenFlags flags, string dbPath = null) { _magic = MagicNative.magic_open(flags); if (_magic == IntPtr.Zero) { throw new MagicException(LastError, "Cannot create magic cookie."); } if (dbPath == null) { dbPath = MagicUtils.GetDefaultMagicPath(); } if (MagicNative.magic_load(_magic, dbPath) != 0) { throw new MagicException(LastError, "Cannot load magic database file."); } }
public MagicOpenFlags GetFlags() { ThrowIfDisposed(); return(MagicNative.magic_getflags(_magic)); }
private void DoDispose() => MagicNative.magic_close(_magic);