public static AudioScanner Load(ADataParser parser, string filename) { if (parser == null) throw new ArgumentNullException("parser"); if (filename == null) throw new ArgumentNullException("filename"); FileInfo file = new FileInfo(filename); if (!file.Exists) throw new ArgumentException(file.FullName + " doesn't exist", "filename"); AudioScanner scanner; using (FileStream fs = new FileStream(file.FullName, FileMode.Open)) { try { scanner = Load(parser, fs); } catch { scanner = null; } } return scanner; }
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; }
public AudioScanner(ADataParser parser, DirectoryInfo directory, SearchOption searchoption, params string[] extensions) { if (parser == null) throw new ArgumentNullException("parser"); if (directory == null) throw new ArgumentNullException("directory"); this.parser = parser; this.directory = directory; this.searchoption = searchoption; extensionList = new ExtensionList(extensions); existingFiles = new ExistingFilesCollection(); worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); }
public AudioScanner(ADataParser parser, string directory, SearchOption searchoption, params string[] extensions) : this(parser, new DirectoryInfo(directory), searchoption, extensions) { }
public AudioScanner(ADataParser parser, DirectoryInfo directory, SearchOption searchoption) : this(parser, directory, searchoption, ".mp3", ".wma") { }
public AudioScanner(ADataParser parser, string directory, SearchOption searchoption) : this(parser, new DirectoryInfo(directory), searchoption) { }
public AudioScanner(ADataParser parser, DirectoryInfo directory) : this(parser, directory, SearchOption.AllDirectories) { }
public AudioScanner(ADataParser parser, string directory) : this(parser, new DirectoryInfo(directory)) { }