Пример #1
0
 private void CreateAddonList()
 {
     addonList         = AcfFile.CreateNew();
     addonListBaseNode = new AcfFile.CompoundNode(CommonConsts.AddonListAcfRootKey, addonList.Root);
     addonList.Root.Add(addonListBaseNode);
     IsAddonListCreated = true;
 }
Пример #2
0
 public AddonsListTxt(string gameDir)
 {
     IsAddonListCreated = false;
     filePath           = Path.Combine(gameDir, CommonConsts.L4d2MainSubdirName, CommonConsts.AddonListTxtFileName);
     try {
         using (var reader = new StreamReader(filePath, Encoding.Default)) {
             addonList         = AcfFile.ParseString(reader.ReadToEnd(), false);
             addonListBaseNode = addonList.Root.GetChild(CommonConsts.AddonListAcfRootKey) as AcfFile.CompoundNode;
             if (addonListBaseNode == null)
             {
                 Debug.WriteLine("Warning: Syntax error within addonlist.txt.");
                 throw new LoadingException();
             }
         }
         dirty = false;
     } catch (FileNotFoundException e) {
         Debug.WriteLine("Warning: Addonlist.txt is not found and will be created");
         Debug.WriteLine(e);
         CreateAddonList();
     } catch (Exception e) {
         Debug.WriteLine("Warning: Addonlist.txt cannot be read, some features would be inaccessible.");
         Debug.WriteLine(e);
         throw new LoadingException();
     }
 }