示例#1
0
        /// <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);
            }
        }
示例#2
0
        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.");
            }
        }
示例#3
0
        public MagicOpenFlags GetFlags()
        {
            ThrowIfDisposed();

            return(MagicNative.magic_getflags(_magic));
        }
示例#4
0
 private void DoDispose() => MagicNative.magic_close(_magic);