/// <summary> /// Firefoxのプロフィールフォルダ内のフォルダをすべて取得する /// </summary> public static FirefoxProfile[] GetProfiles(string moz_path, string iniFileName) { string profile_path = Path.Combine(moz_path, iniFileName); List<FirefoxProfile> results = new List<FirefoxProfile>(); if (!File.Exists(profile_path)) { return results.ToArray(); } using (StreamReader sr = new StreamReader(profile_path)) { FirefoxProfile prof = null; foreach (string line in EachLines(sr)) { if (line.StartsWith("[Profile")) { prof = new FirefoxProfile(); results.Add(prof); } if (prof != null) { KeyValuePair<string, string> kvp = GetKVP(line); switch (kvp.Key) { case "Name": prof.Name = kvp.Value; break; case "IsRelative": prof.IsRelative = (kvp.Value == "1"); break; case "Path": prof.FilePath = kvp.Value.Replace('/', '\\'); if (prof.IsRelative) { prof.FilePath = Path.Combine(moz_path, prof.FilePath); } break; case "Default": prof.IsDefault = (kvp.Value == "1"); break; } } } } return results.ToArray(); }
/// <summary> /// 指定のfirefoxプロファイルからクッキーを取得します。 /// </summary> private ICookieGetter CreateCookieGetter(FirefoxProfile prof) { string name = "Firefox"; string path = null; if (prof != null) { name += " " + prof.Name; path = Path.Combine(prof.FilePath, COOKEFILE_NAME); } CookieStatus status = new CookieStatus( name, path, BrowserType, PathType.File); return new FirefoxCookieGetter(status); }
public ICookieGetter[] CreateCookieGetters() { FirefoxProfile[] profs = FirefoxProfile.GetProfiles( CookieUtil.ReplacePathSymbols(DATAFOLDER), INIFILE_NAME); if (profs.Length == 0) { return(new ICookieGetter[] { CreateCookieGetter(null) }); } ICookieGetter[] cgs = new ICookieGetter[profs.Length]; for (int i = 0; i < profs.Length; i++) { cgs[i] = CreateCookieGetter(profs[i]); } return(cgs); }