Beispiel #1
0
        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);
            }
        }
Beispiel #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.");
            }
        }