/// <summary> /// This method will scan a given file using the options passed in. /// /// It will return a ClamResult, which can be null if no virus is found. /// </summary> /// <returns> /// A ClamResult object (or null). /// </returns> /// <param name='filepath'> /// The path to the file to be scanned. /// </param> /// <param name='options'> /// The options to perform the scan with. /// </param> 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 if (ret == ClamReturnCode.CL_EOPEN) { Console.WriteLine("Could not open " + filepath); } else { throw new Exception("Expected either CL_CLEAN or CL_VIRUS, got: " + ret); } return(null); }
/// <summary> /// This method will scan a given file using the options passed in. /// /// It will return a ClamResult, which can be null if no virus is found. /// </summary> /// <returns> /// A ClamResult object (or null). /// </returns> /// <param name='filepath'> /// The path to the file to be scanned. /// </param> /// <param name='options'> /// The options to perform the scan with. /// </param> 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 if (ret == ClamReturnCode.CL_EOPEN) Console.WriteLine("Could not open " + filepath); else throw new Exception("Expected either CL_CLEAN or CL_VIRUS, got: " + ret); return null; }