public void LoadDatabaseFromCustomPathIsSuccessful() { _clamEngine.LoadDatabase(Path.Combine(TestHelpers.TestFilesDirectory, "db")); Assert.That(_clamEngine.DatabaseOptions, Is.Not.EqualTo(0)); Assert.That(_clamEngine.DatabaseTime, Is.Not.EqualTo(0)); Assert.That(_clamEngine.DatabaseVersion, Is.Not.EqualTo(0)); }
/// <summary> /// Creates a new ClamAV engine instance. /// </summary> protected override void ProcessRecord() { var clamEngine = new ClamEngine(DebugMode.IsPresent); if (!String.IsNullOrEmpty(WithDatabase)) clamEngine.LoadDatabase(WithDatabase); WriteObject(clamEngine); }
/// <summary> /// Creates a new ClamAV engine instance. /// </summary> protected override void ProcessRecord() { var clamEngine = new ClamEngine(DebugMode.IsPresent); if (!String.IsNullOrEmpty(WithDatabase)) { clamEngine.LoadDatabase(WithDatabase); } WriteObject(clamEngine); }
public ScanForm() { // Windows Forms setup. InitializeComponent(); this.Icon = SystemIcons.Shield; // Instantiate ClamAV engine. _clamAV = new ClamEngine(); logTextBox.AppendText("ClamAV Version: " + _clamAV.Version + "\r\n"); logTextBox.AppendText("Loading signatures from default location...\r\n"); // Disable user input while loading. scanPathTextBox.Enabled = false; browseButton.Enabled = false; scanButton.Enabled = false; // Load signatures on a new thread. Thread setupThread = new Thread(() => { try { // Load database from the default location. _clamAV.LoadDatabase(); // Signal database load is complete. this.Invoke(new Action(() => { logTextBox.AppendText("Signatures loaded.\r\n"); scanPathTextBox.Enabled = true; browseButton.Enabled = true; scanButton.Enabled = true; })); } catch (Exception ex) { // Report exception to user. this.Invoke(new Action(() => { logTextBox.AppendText("Failed to load signatures:\r\n"); logTextBox.AppendText(ex.ToString()); })); } }); // Begin work. setupThread.Start(); }
public ScanForm() { // Windows Forms setup. InitializeComponent(); this.Icon = SystemIcons.Shield; // Instantiate ClamAV engine. _clamAV = new ClamEngine(); logTextBox.AppendText("ClamAV Version: " + ClamEngine.Version + "\r\n"); logTextBox.AppendText("Loading signatures from default location...\r\n"); // Disable user input while loading. scanPathTextBox.Enabled = false; browseButton.Enabled = false; scanButton.Enabled = false; // Load signatures on a new thread. Thread setupThread = new Thread(() => { try { // Load database from the default location. _clamAV.LoadDatabase(); // Signal database load is complete. this.Invoke(new Action(() => { logTextBox.AppendText("Signatures loaded.\r\n"); scanPathTextBox.Enabled = true; browseButton.Enabled = true; scanButton.Enabled = true; })); } catch (Exception ex) { // Report exception to user. this.Invoke(new Action(() => { logTextBox.AppendText("Failed to load signatures:\r\n"); logTextBox.AppendText(ex.ToString()); })); } }); // Begin work. setupThread.Start(); }
public Main() { InitializeComponent(); clamAV = new ClamEngine(); Text = Text + " ClamAV Engine Version : " + ClamEngine.Version; Icon = SystemIcons.Shield; Thread SetupThread = new Thread(() => { try { clamAV.LoadDatabase(AppDomain.CurrentDomain.BaseDirectory + @"\database\main.cvd", LoadOptions.OfficialOnly); } catch (Exception ex) { if (InvokeRequired) { Text = "Failed to load signature"; } } }); SetupThread.Start(); }
/// <summary> /// Asynchronously loads a database file or directory into the engine. /// </summary> /// <param name="engine">ClamAV engine instance.</param> /// <param name="path">Path to the database file or a directory containing database files.</param> /// <param name="options">Options with which to load the database.</param> /// <returns>The task object representing the asynchronous operation.</returns> public static async Task LoadDatabaseAsync(this ClamEngine engine, string path, LoadOptions options) { await Task.Factory.StartNew(() => engine.LoadDatabase(path, options)); }