private ICookieGetter CreateCookieGetter(FirefoxProfile prof)
        {
            string name = "PaleMoon";
            string path = null;

            if (prof != null) {
                name += " " + prof.name;
                path = System.IO.Path.Combine(prof.path, COOKEFILE_NAME);
            }

            CookieStatus status = new CookieStatus(name, path, this.BrowserType, PathType.File);
            return new FirefoxCookieGetter(status);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Firefoxのプロフィールフォルダ内のフォルダをすべて取得する
        /// </summary>
        /// <returns></returns>
        public static FirefoxProfile[] GetProfiles(string moz_path, string iniFileName)
        {
            string profile_path = System.IO.Path.Combine(moz_path, iniFileName);

            List<FirefoxProfile> results = new List<FirefoxProfile>();

            if (System.IO.File.Exists(profile_path)) {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(profile_path)) {
                    FirefoxProfile prof = null;
                    while (!sr.EndOfStream) {
                        string line = sr.ReadLine();

                        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.path = kvp.Value.Replace('/', '\\');
                                    if (prof.isRelative) {
                                        prof.path = System.IO.Path.Combine(moz_path, prof.path);
                                    }
                                    break;
                                case "Default":
                                    prof.isDefault = kvp.Value == "1";
                                    break;
                            }
                        }
                    }
                }

            }

            return results.ToArray();
        }