public bool Locate(string path, out string outPath, out string[] checkedPaths) { if (!path.StartsWith(Path.DirectorySeparatorChar.ToString())) { path = "{0}{1}"._Format(Path.DirectorySeparatorChar.ToString(), path); } string ext = Path.GetExtension(path).ToLowerInvariant(); string foundPath = string.Empty; string checkNext = Fs.CleanPath("~" + path); Fs fs = ContentRoot; List <string> pathsChecked = new List <string> { checkNext }; if (!fs.FileExists(checkNext, out foundPath)) { foundPath = string.Empty; SearchRule[] extRules = _searchRules.Where(sr => sr.Ext.ToLowerInvariant().Equals(ext)).ToArray(); extRules.Each(rule => { rule.SearchDirectories.Each(dir => { List <string> segments = new List <string>(); segments.AddRange(dir.RelativePath.DelimitSplit("/", "\\")); segments.AddRange(path.DelimitSplit("/", "\\")); string subPath = Path.Combine(segments.ToArray()); checkNext = Fs.CleanPath(subPath); pathsChecked.Add(checkNext); if (fs.FileExists(checkNext, out foundPath)) { return(false); // stop the each loop } else { foundPath = string.Empty; } return(true); // continue the each loop }); if (!string.IsNullOrEmpty(foundPath)) { return(false); // stop the each loop } return(true); // continue the each loop }); } checkedPaths = pathsChecked.ToArray(); outPath = foundPath; return(!string.IsNullOrEmpty(foundPath)); }
protected static internal string[] GetPageScripts(AppConf appConf) { BamApplicationManager manager = new BamApplicationManager(appConf.BamConf); string[] pageNames = manager.GetPageNames(appConf.Name); List <string> results = new List <string>(); pageNames.Each(pageName => { string script = "/" + Fs.CleanPath(Path.Combine("pages", pageName + ".js")).Replace("\\", "/"); // for use in html if (appConf.AppRoot.FileExists(script)) { results.Add(script); } }); return(results.ToArray()); }