/// <summary> /// Background search /// </summary> private void BackgroundRun() { pathModel.Updating = true; try { if (pathModel.IsVirtual) { string ext = Path.GetExtension(pathModel.Path).ToLower(); if (ext == ".jar" || ext == ".zip") { pathModel.WasExplored = true; ExtractFilesFromArchive(); } // let the context explore packaged libraries else if (pathModel.Owner != null) try { NotifyProgress(String.Format(TextHelper.GetString("Info.Parsing"), 1), 0, 1); pathModel.Owner.ExploreVirtualPath(pathModel); } catch (Exception ex) { MessageBox.Show(ex.Message, TextHelper.GetString("Info.SWCConversionException")); } } else { pathModel.WasExplored = true; bool writeCache = false; string cacheFileName = null; if (UseCache) { cacheFileName = GetCacheFileName(pathModel.Path); if (File.Exists(cacheFileName)) { NotifyProgress(TextHelper.GetString("Info.ParsingCache"), 0, 1); ASFileParser.ParseCacheFile(pathModel, cacheFileName, context); } if (stopExploration) return; } else writeCache = true; // explore filesystem (populates foundFiles) ExploreFolder(pathModel.Path, context.GetExplorerMask()); if (stopExploration) return; // create models writeCache |= ParseFoundFiles(); // write cache file if (UseCache && writeCache && !stopExploration) try { string cacheDir = Path.GetDirectoryName(cacheFileName); if (!Directory.Exists(cacheDir)) Directory.CreateDirectory(cacheDir); else if (File.Exists(cacheFileName)) File.Delete(cacheFileName); if (pathModel.Files.Values.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (FileModel model in pathModel.Files.Values) { sb.Append("\n#file-cache ").Append(model.FileName).Append('\n'); sb.Append(model.GenerateIntrinsic(true)); } string src = sb.ToString(); FileHelper.WriteFile(cacheFileName, src, Encoding.UTF8); } } catch { } } } finally { pathModel.Updating = false; } }