Exemple #1
0
        public static string Description(byte[] buffer)
        {
            Magic m = new Magic(false);

            magic_setflags(m._magic, DefaultFlags);
            var result = magic_buffer(m._magic, buffer, buffer.Length);
            var desc = Marshal.PtrToStringAnsi(result);

            if (desc == null)
            {
                throw new MagicException(m.Error);
            }

            return desc;
        }
Exemple #2
0
        public static string Mime(string filename)
        {
            string mime;
            Magic m = new Magic(true);

            mime = Marshal.PtrToStringAuto(magic_file(m._magic, filename));
            if (mime == null)
            {
                throw new MagicException(m.Error);
            }

            return mime;
        }
Exemple #3
0
        public static string Description(string filename)
        {
            Magic m = new Magic(false);

            magic_setflags(m._magic, DefaultFlags);
            var result = magic_file(m._magic, filename);
            var desc = Marshal.PtrToStringAnsi(result);

            if (desc == null)
            {
                throw new MagicException(m.Error);
            }

            return desc;
        }