예제 #1
0
파일: Magic.cs 프로젝트: ntserver2003/Mime
        /// <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
파일: Magic.cs 프로젝트: pombredanne/Mime-1
        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
파일: Magic.cs 프로젝트: pombredanne/Mime-1
        public MagicOpenFlags GetFlags()
        {
            ThrowIfDisposed();

            return(MagicNative.magic_getflags(_magic));
        }
예제 #4
0
파일: Magic.cs 프로젝트: pombredanne/Mime-1
 private void DoDispose() => MagicNative.magic_close(_magic);