LynnaLab.FileParser.Save C# (CSharp) Method

Save() public method

public Save ( ) : void
return void
        public void Save()
        {
            if (!Modified) return;

            List<string> output = new List<string>();
            FileComponent lastComponent = null;
            for (int i=0;i<fileStructure.Count;i++) {
                string s = null;

                FileComponent d = fileStructure[i];
                if (d.Fake)
                    s = null;
                else {
                    s = "";
                    if (lastComponent != null && !lastComponent.EndsLine) {
                        s = output[output.Count-1];
                        output.RemoveAt(output.Count-1);
                    }
                    s += d.GetString();
                    if (d.EndsLine)
                        s += fileStructureComments[i];
                }

                if (s != null)
                    output.Add(s);

                if (d is Data)
                    (d as Data).Modified = false;

                lastComponent = d;
            }
            File.WriteAllLines(FullFilename, output);

            Modified = false;
        }