void OnVolumeInsertedRemoved(string volume, string serial) { MPTVSeriesLog.Write("On Volume Inserted or Removed: " + volume); List <String> folders = new List <String>(); foreach (DBImportPath importPath in DBImportPath.GetAll()) { string sRoot = System.IO.Path.GetPathRoot(importPath[DBImportPath.cPath]); if ((importPath[DBImportPath.cEnabled] != 0) && !String.IsNullOrEmpty(sRoot) && sRoot.ToLower().StartsWith(volume.ToLower())) { MPTVSeriesLog.Write("Adding for import or remove: " + importPath[DBImportPath.cPath]); folders.Add(importPath[DBImportPath.cPath]); } } if (folders.Count > 0) { List <PathPair> m_PreviousScanRemovableTemp = new List <PathPair>(); m_PreviousScanRemovableTemp.AddRange(m_PreviousScanRemovable); foreach (String pair in folders) { m_PreviousScanRemovableTemp.RemoveAll(item => !item.m_sFull_FileName.StartsWith(pair)); } foreach (PathPair pair in m_PreviousScanRemovableTemp) { m_PreviousScanRemovable.RemoveAll(item => item.m_sFull_FileName == pair.m_sFull_FileName); } DoFileScan(folders, ref m_PreviousScanRemovableTemp); m_PreviousScanRemovable.AddRange(m_PreviousScanRemovableTemp); } }
public static void StartMonitor() { if (MonitorStarted) { return; } DBImportPath[] importPaths = DBImportPath.GetAll(); if (importPaths != null) { foreach (DBImportPath currPath in importPaths) { try { AddWatchDrive(currPath[DBImportPath.cPath]); } catch (Exception e) { if (e is ThreadAbortException) { throw e; } MPTVSeriesLog.Write("Failed adding " + currPath + " to the Disk Watcher!", MPTVSeriesLog.LogLevel.Debug); } } } }
List <String> GetDeviceManagerWatchedFolders() { List <String> result = new List <String>(); if (DeviceManager.watchedDrives == null) { return(result); } foreach (DBImportPath importPath in DBImportPath.GetAll()) { string sRoot = System.IO.Path.GetPathRoot(importPath[DBImportPath.cPath]); string importPathString = importPath[DBImportPath.cPath]; if (!String.IsNullOrEmpty(importPathString) && (importPath[DBImportPath.cEnabled] != 0) && !String.IsNullOrEmpty(sRoot)) { foreach (String drive in DeviceManager.watchedDrives) { if (importPathString.StartsWith(drive) && !result.Contains(importPathString)) { result.Add(importPathString); } } } } return(result); }
//public static bool isOnRemovable(string filename) //{ // if (paths == null) paths = DBImportPath.GetAll(); // foreach (DBImportPath path in paths) // { // if (path[DBImportPath.cRemovable] && filename.ToLower().Contains(path[DBImportPath.cPath].ToString().ToLower())) return true; // } // return false; //} //public static bool needToKeepReference(string filename) //{ // if (paths == null) paths = DBImportPath.GetAll(); // foreach (DBImportPath path in paths) // { // if (path[DBImportPath.cKeepReference] && filename.ToLower().Contains(path[DBImportPath.cPath].ToString().ToLower())) return true; // } // return false; //} /// <summary> /// Gets the corresponding Import Path that the filename is attached to /// </summary> public static string getImportPath(string filename) { if (paths == null) { paths = DBImportPath.GetAll(); } if (paths != null) { foreach (DBImportPath path in paths) { string importPath = path[DBImportPath.cPath]; if (filename.ToLower().Contains(importPath.ToString().ToLower())) { return(importPath); } } } return(null); }
private void worker_DoWork(object sender, DoWorkEventArgs e) { System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest; List <String> listFolders = new List <string>(); DBImportPath[] importPathes = DBImportPath.GetAll(); if (importPathes != null) { foreach (DBImportPath importPath in importPathes) { if (importPath[DBImportPath.cEnabled] != 0) { listFolders.Add(importPath[DBImportPath.cPath]); } } } List <PathPair> files = Filelister.GetFiles(listFolders); MPTVSeriesLog.Write("Found " + files.Count.ToString() + " supported video files in your import paths"); e.Result = Parse(files); }