public void SetUpClamEngine()
        {
            if (!TestHelpers.NativeLibraryExists())
                Assert.Ignore("libclamav dynamic library is missing from the unit test binary directory.");

            _clamEngine = new ClamEngine();
        }
        public void SetUp()
        {
            if (!TestHelpers.TestFilesDirectoryExists())
                Assert.Ignore("TestFiles directory is missing.");

            _clamEngine = new ClamEngine();
        }
 public void TearDownClamEngine()
 {
     if (_clamEngine != null)
     {
         _clamEngine.Dispose();
         _clamEngine = null;
     }
 }
        /// <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);
        }
Exemple #5
0
        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 void SetUpClamEngine()
 {
     _clamEngine = new ClamEngine();
 }
        public MainWindowViewModel()
        {
            ScanCommand = new RelayCommand(OnScan, CanScan);
            LoadCommand = new RelayCommand(OnLoad);

            try
            {
                Busy = true;

                _clamEngine = new ClamEngine();
                WriteLogLine("ClamAV version " + ClamEngine.Version);
            }
            catch (Exception ex)
            {
                WriteLogLine("Failed to load engine:");
                WriteLogLine(ex.ToString());
            }
            finally
            {
                Busy = false;
            }
        }