コード例 #1
0
ファイル: FileEntry.cs プロジェクト: bertsinnema/MClam
        /// <summary>
        ///  Initialize new instance of <see cref="FileEntry"/>.
        /// </summary>
        /// <param name="filePath">Fullpath to file.</param>
        /// <returns><see cref="FileEntry"/> object from specified file.</returns>
        public static FileEntry Open(string filePath)
        {
            ArgValidate.NotEmptyString(filePath, nameof(filePath));
            ArgValidate.FileExist(filePath, nameof(filePath));

            return(new FileEntry(filePath));
        }
コード例 #2
0
        /// <summary>
        /// Initialize new instance of <see cref="HashDatabaseWriter"/> with specified hash type.
        /// </summary>
        /// <param name="outputPath">Fullpath output directory.</param>
        /// <param name="fileName">Database file name (without extension, the extension will selected automatically).</param>
        /// <param name="type">Hash type.</param>
        /// <param name="append">Specifies that this writer is appending not overwriting.</param>
        public HashDatabaseWriter(string outputPath, string fileName, DatabaseType type, bool append)
        {
            ArgValidate.NotEmptyString(outputPath, nameof(outputPath));
            ArgValidate.DirectoryExist(outputPath, nameof(outputPath));
            ArgValidate.NotEmptyString(fileName, nameof(fileName));
            ArgValidate.FileExist(fileName, nameof(fileName));

            var fname = string.Copy(fileName);

            switch (type)
            {
            case DatabaseType.Sha1Hash:
                fname += ".hsb";
                break;

            case DatabaseType.Sha256Hash:
                fname += ".hsb";
                break;

            case DatabaseType.Md5Hash:
                fname += ".hdb";
                break;

            case DatabaseType.PeSectionHash:
                fname += ".msb";
                break;
            }

            _type   = type;
            _writer = new StreamWriter(Path.Combine(outputPath, fname), append)
            {
                NewLine = "\n"
            };
        }
コード例 #3
0
ファイル: ClamEngine.cs プロジェクト: bertsinnema/MClam
        /// <summary>
        /// Scans a file for viruses.
        /// </summary>
        /// <param name="path">Full path to file to be scanned.</param>
        /// <returns><see cref="ScanResult"/> object containing scan information.</returns>
        public ScanResult ScanFile(string path)
        {
            ArgValidate.NotEmptyString(path, nameof(path));
            ArgValidate.FileExist(path, nameof(path));

            return(ScanFile(FileEntry.Open(path)));
        }
コード例 #4
0
        internal ClamavDatabaseFile(string file, cl_cvd data)
        {
            ArgValidate.NotNull(data, nameof(data));
            ArgValidate.NotNull(file, nameof(file));
            ArgValidate.FileExist(file, nameof(file));

            FullPath = file;
            _data    = data;
        }
コード例 #5
0
ファイル: UpdateChecker.cs プロジェクト: bertsinnema/MClam
        /// <summary>
        /// Checks for database update from specified local database and remote database.
        /// </summary>
        /// <param name="cvdPath">Full path to local CVD file.</param>
        /// <param name="url">URI path to remote CVD file.</param>
        /// <returns><c>True</c> when update is availiable, otherwise <c>False</c>.</returns>
        public bool HasUpdate(string cvdPath, string url)
        {
            ArgValidate.NotEmptyString(cvdPath, nameof(cvdPath));
            ArgValidate.FileExist(cvdPath, nameof(cvdPath));

            var remoteTime = GetRemoteVersion(url);
            var local      = SigtoolMain.GetCvdMetadata(cvdPath);

            return(remoteTime > local.Version);
        }