protected override bool TouchFile(string path)
        {
            // Prüfen der Eingaben im Debug- Zweig
            Debug.Assert(System.IO.File.Exists(path), "Datei " + path + "existiert nicht");
            ContentVector newContentVec;

            if (_classificator.classify(path, out newContentVec))
            {
                _contentVec += newContentVec;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        // Überschreiben der virtuellen Methoden der Basisklasse
        protected override bool BeginScanDir(string path)
        {
            // Prüfung der Eingabe im Debugzweig
            Debug.Assert(System.IO.Directory.Exists(path), path + "existiert nicht");

            _contentVec = new ContentVector();

            if (!_writer.Open())
            {
                return(false);
            }

            Trace.WriteLineIf(FileClassificatorServerSwitch.TraceInfo, "Scan startete um " + DateTime.Now.ToLongTimeString());

            return(true);
        }
        protected override bool ExitDir(string path)
        {
            // Prüfen im Debugzweig
            Debug.Assert(_stack.Count > 0, "Stack ist vorzeitig geleert worden");

            int           Tiefe = _stack.Count;
            ContentVector Vec   = _contentVec - _stack.Pop();

            // Dokumentiern im Debugzweig
            Trace.WriteLineIf(FileClassificatorServerSwitch.TraceInfo, "Tiefe= " + Tiefe + " " + path + " SizeInBytes= " + Vec.SizeInBytes);

            if (!_writer.Write(Tiefe, path, Vec))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        public static ContentVector operator -(ContentVector a, ContentVector b)
        {
            ContentVector sum = new ContentVector();

            sum.ArchiveBitSetCount       = a.ArchiveBitSetCount - b.ArchiveBitSetCount;
            sum.ArchiveBitSetSizeInBytes = a.ArchiveBitSetSizeInBytes - b.ArchiveBitSetSizeInBytes;
            sum.FotosCount            = a.FotosCount - b.FotosCount;
            sum.FotosSizeInBytes      = a.FotosSizeInBytes - b.FotosSizeInBytes;
            sum.OfficeCount           = a.OfficeCount - b.OfficeCount;
            sum.OfficeSizeInBytes     = a.OfficeSizeInBytes - b.OfficeSizeInBytes;
            sum.OtherCount            = a.OtherCount - b.OtherCount;
            sum.OtherSizeInBytes      = a.OtherSizeInBytes - b.OtherSizeInBytes;
            sum.SourceCodeCount       = a.SourceCodeCount - b.SourceCodeCount;
            sum.SourceCodeSizeInBytes = a.SourceCodeSizeInBytes - b.SourceCodeSizeInBytes;
            sum.VideosCount           = a.VideosCount - b.VideosCount;
            sum.VideosSizeInBytes     = a.VideosSizeInBytes - b.VideosSizeInBytes;
            sum.WebCount       = a.WebCount - b.WebCount;
            sum.WebSizeInBytes = a.WebSizeInBytes - b.WebSizeInBytes;
            return(sum);
        }
Esempio n. 5
0
        public object Clone()
        {
            ContentVector vec = new ContentVector();

            vec.ArchiveBitSetCount       = ArchiveBitSetCount;
            vec.ArchiveBitSetSizeInBytes = ArchiveBitSetSizeInBytes;
            vec.FotosCount            = FotosCount;
            vec.FotosSizeInBytes      = FotosSizeInBytes;
            vec.OfficeCount           = OfficeCount;
            vec.OfficeSizeInBytes     = OfficeSizeInBytes;
            vec.OtherCount            = OtherCount;
            vec.OtherSizeInBytes      = OtherSizeInBytes;
            vec.SourceCodeCount       = SourceCodeCount;
            vec.SourceCodeSizeInBytes = SourceCodeSizeInBytes;
            vec.VideosCount           = VideosCount;
            vec.VideosSizeInBytes     = VideosSizeInBytes;
            vec.WebCount       = WebCount;
            vec.WebSizeInBytes = WebSizeInBytes;

            return(vec);
        }
        bool IFileClassificator.classify(string Filename, out ContentVector vec)
        {
            vec = new ContentVector();
            // 1. Merkmale der Datei bestimmen
            long sizeInBytes = 0;

            try
            {
                FileStream fs = File.Open(Filename, FileMode.Open, FileAccess.Read);
                sizeInBytes = fs.Length;
                fs.Close();
            }
            catch (Exception)
            {
            }

            FileAttributes fatt = File.GetAttributes(Filename);

            string ext = Path.GetExtension(Filename);

            // 2. Merkmale bewerten

            if ((fatt & FileAttributes.Archive) != 0)
            {
                vec.ArchiveBitSetCount       = 1;
                vec.ArchiveBitSetSizeInBytes = sizeInBytes;
            }

            switch (ext.ToLower())
            {
            case ".htm":
            case ".html":
            case ".js":
            case ".gif":
            case ".png":
                vec.WebCount       = 1;
                vec.WebSizeInBytes = sizeInBytes;
                break;

            case ".xml":
            case ".cpp":
            case ".vb":
            case ".vbs":
            case ".cs":
            case ".pl":
                vec.SourceCodeCount       = 1;
                vec.SourceCodeSizeInBytes = sizeInBytes;
                break;

            case ".odt":
            case ".odg":
            case ".ods":
            case ".odf":
            case ".pdf":
            case ".txt":
            case ".xls":
            case ".ppt":
            case ".doc":
                vec.OfficeCount       = 1;
                vec.OfficeSizeInBytes = sizeInBytes;
                break;

            case ".jpg":
            case ".tiff":
            case ".bmp":
                if (sizeInBytes < 1024 * 100)
                {
                    vec.WebCount       = 1;
                    vec.WebSizeInBytes = sizeInBytes;
                }
                else
                {
                    vec.FotosCount       = 1;
                    vec.FotosSizeInBytes = sizeInBytes;
                }
                break;

            case ".avi":
            case ".mov":
            case ".rm":
            case ".wmv":
                vec.VideosCount       = 1;
                vec.VideosSizeInBytes = sizeInBytes;
                break;

            default:
                vec.OtherCount       = 1;
                vec.OtherSizeInBytes = sizeInBytes;
                break;
            }

            return(true);
        }
Esempio n. 7
0
 public bool Write(int Tiefe, string path, ContentVector vec)
 {
     Debug.Assert(!string.IsNullOrEmpty(path) && vec != null);
     _lst.Add((ContentVector)vec.Clone());
     return(true);
 }