static void Process(Argument cmdline) { if (cmdline.IsTest) { Trans.Test(cmdline); return; } // 各ファイルに対する処理 System.Text.StringBuilder bcontent = new System.Text.StringBuilder(); foreach (string file in cmdline.FileNames) { string content1 = System.IO.File.ReadAllText(file, System.Text.Encoding.UTF8); if (cmdline.Verbose) { cmdline.WriteLine("gzjs: read from {0}.", file); } content1 = Trans.ProcessSource(content1, cmdline); if (cmdline.TokenReplacing) { content1 = Trans.GenerateTokenReplacing2(content1, cmdline); } bcontent.Append(content1); } // 全体に対する処理 string content = bcontent.ToString(); if (cmdline.IsSfx85) { content = Trans.CreateSfx85(content); } else if (cmdline.IsSfx) { content = Trans.CreateSfx(content); } content = content.Replace("\r\n", "\n"); // 書込 if (cmdline.IsGzipCompress) { string gzfile = cmdline.OutputFile; if (cmdline.OutputFile == "-") { using (System.IO.Stream stdout = System.Console.OpenStandardOutput()) IO.SaveAsGzipFile(stdout, content); } else { IO.SaveAsGzipFile(gzfile, content); } // <gzip.exe を使う場合> // string tempfile=System.IO.Path.Combine(IO.path_temp, System.IO.Path.GetFileName(cmdline.OutputFile)); // writeFile(tempfile, content); // string gzfile=cmdline.OutputFile+".gz"; // IO.gzip(tempfile, gzfile, false); // </gzip> if (cmdline.Verbose) { cmdline.WriteLine("gzjs: wrote to {0}.", gzfile); } } else { string outfile = cmdline.OutputFile; if (outfile == "-") { System.Console.Write(content); } else { writeFile(outfile, content); } if (cmdline.Verbose) { cmdline.WriteLine("gzjs: wrote to {0}.", outfile); } } }