Exemplo n.º 1
0
        public ClamResult ScanFile(string filepath, uint options = (uint)ClamScanOptions.CL_SCAN_STDOPT)
        {
            ulong          scanned = 0;
            IntPtr         vname   = (IntPtr)null;
            ClamReturnCode ret     = ClamBindings.cl_scanfile(filepath, ref vname, ref scanned, engine, options);

            if (ret == ClamReturnCode.CL_VIRUS)
            {
                string virus = Marshal.PtrToStringAnsi(vname);

                ClamResult result = new ClamResult();
                result.ReturnCode = ret;
                result.VirusName  = virus;
                result.FullPath   = filepath;

                return(result);
            }
            else if (ret == ClamReturnCode.CL_CLEAN)
            {
                return(null);
            }
            else
            {
                throw new Exception("Expected either CL_CLEAN or CL_VIRUS, got: " + ret);
            }
        }
Exemplo n.º 2
0
        public ClamResult ScanFile(string filepath, uint options)
        {
            ulong scanned = 0;
            IntPtr vname = (IntPtr)null;
            ClamReturnCode ret = ClamBindings.cl_scanfile(filepath, ref vname, ref scanned, engine, options);

            if (ret == ClamReturnCode.CL_VIRUS) {
                string virus = Marshal.PtrToStringAnsi (vname);

                ClamResult result = new ClamResult ();
                result.ReturnCode = ret;
                result.VirusName = virus;
                result.FullPath = filepath;

                return result;
            } else if (ret == ClamReturnCode.CL_CLEAN)
                return null;
            else
                throw new Exception ("Expected either CL_CLEAN or CL_VIRUS, got: " + ret);
        }