예제 #1
0
        void AddSourceFile(string sourceFile)
        {
            StreamReader sr = null;
            StreamWriter sw = null;

            try
            {
                sr = new StreamReader(outFile + ".sources");
                sw = new StreamWriter(outFile + ".sources.new");

                string newFile = project.GetRelativeChildPath(sourceFile);
                if (newFile.StartsWith("./"))
                {
                    newFile = newFile.Substring(2);
                }

                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    string file = line.Trim(' ', '\t');
                    if (newFile != null && (file == "" || string.Compare(file, newFile) > 0))
                    {
                        sw.WriteLine(newFile);
                        newFile = null;
                    }
                    sw.WriteLine(line);
                }
                if (newFile != null)
                {
                    sw.WriteLine(newFile);
                }
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
                if (sw != null)
                {
                    sw.Close();
                }
            }
            File.Delete(outFile + ".sources");
            File.Move(outFile + ".sources.new", outFile + ".sources");
        }