Пример #1
0
        public static void Save(AudioScanner ac, Stream output)
        {
            if (output == null)
                throw new ArgumentNullException("output");
            if (!output.CanWrite)
                throw new ArgumentException("Output stream must support writing", "output");

            IOAssistant io = new IOAssistant(output);
            io.Write(ac.directory.FullName);
            io.Write(ac.extensionList.Count);
            for (int i = 0; i < ac.extensionList.Count; i++)
                io.Write(ac.extensionList[i]);

            FlagByte1 fb1 = FlagByte1.NoFlags;
            if (ac.searchoption == SearchOption.AllDirectories)
                fb1 = fb1 | FlagByte1.AllDirectories;
            if (ac.ParseAdd)
                fb1 = fb1 | FlagByte1.ParseAdd;
            if (ac.ParseUpdate)
                fb1 = fb1 | FlagByte1.ParseUpdate;
            if (ac.RemoveDeadFiles)
                fb1 = fb1 | FlagByte1.RemoveDeadFiles;
            if (ac.ScannerReportsProgress)
                fb1 = fb1 | FlagByte1.ReportsProgress;
            output.WriteByte((byte)fb1);

            io.Write(ac.existingFiles.Count);
            foreach (RawTrack rt in ac.existingFiles)
            {
                rt.Save(output);
            }
        }
        public ScannerBackgroundWorker(AudioScanner scanner)
        {
            if (scanner == null)
                throw new ArgumentNullException("scanner");

            this.scanner = scanner;
            scanner.FileParsed += scanner_FileParsed;

            worker = new BackgroundWorker();
            worker.WorkerReportsProgress = true;
            worker.DoWork += worker_DoWork;
            worker.ProgressChanged += worker_ProgressChanged;
            worker.RunWorkerCompleted += worker_RunWorkerCompleted;
        }
Пример #3
0
        public static AudioScanner Load(ADataParser parser, Stream input)
        {
            if (parser == null)
                throw new ArgumentNullException("parser");
            if (input == null)
                throw new ArgumentNullException("input");
            if (!input.CanRead)
                throw new ArgumentException("Input stream must support reading", "input");

            IOAssistant io = new IOAssistant(input);

            string path = io.ReadString();
            DirectoryInfo directory = new DirectoryInfo(path);

            int extCount = io.ReadInt32();
            string[] extensions = new string[extCount];
            for (int i = 0; i < extCount; i++)
                extensions[i] = io.ReadString();

            FlagByte1 flagbyte1 = (FlagByte1)input.ReadByte();
            SearchOption searchoption = SearchOption.TopDirectoryOnly;
            if ((flagbyte1 & FlagByte1.AllDirectories) == FlagByte1.AllDirectories)
                searchoption = SearchOption.AllDirectories;

            AudioScanner ac = new AudioScanner(parser, directory, searchoption, extensions);

            ac.ParseAdd = (flagbyte1 & FlagByte1.ParseAdd) == FlagByte1.ParseAdd;
            ac.ParseUpdate = (flagbyte1 & FlagByte1.ParseUpdate) == FlagByte1.ParseUpdate;
            ac.RemoveDeadFiles = (flagbyte1 & FlagByte1.RemoveDeadFiles) == FlagByte1.RemoveDeadFiles;
            ac.ScannerReportsProgress = (flagbyte1 & FlagByte1.ReportsProgress) == FlagByte1.ReportsProgress;

            int existCount = io.ReadInt32();
            for (int i = 0; i < existCount; i++)
                ac.existingFiles.Add(RawTrack.FromStream(input));

            return ac;
        }