Exemplo n.º 1
0
 public Magic(MagicOpenFlags flags, string dbPath = null)
 {
     _magic = MagicNative.magic_open(flags);
     if (_magic == IntPtr.Zero)
     {
         throw new MagicException("Cannot create magic cookie.");
     }
     if (MagicNative.magic_load(_magic, dbPath) != 0)
     {
         throw new MagicException(LastError);
     }
 }
Exemplo n.º 2
0
 public Magic(MagicOpenFlags flags, string dbPath = null)
 {
     _magic = MagicNative.magic_open(flags);
     if (_magic == IntPtr.Zero)
     {
         throw new Exception("Failed to initialize file type detection library: " + LastError);
     }
     if (MagicNative.magic_load(_magic, dbPath) != 0)
     {
         throw new Exception("File type detection database not found: " + LastError);
     }
 }
Exemplo n.º 3
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.");
            }
        }