From 74698bdea28d733162e69d211a3517e9f0be6e79 Mon Sep 17 00:00:00 2001 From: ouczbs Date: Sat, 6 Jul 2024 16:12:09 +0800 Subject: [PATCH] =?UTF-8?q?cpp=5Finput=20=E7=94=9F=E6=88=90=E5=9C=A8?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=9B=AE=E5=BD=95=20appdata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/refl/BuildOption.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/refl/BuildOption.cs b/src/refl/BuildOption.cs index 2072924..c71ca0c 100644 --- a/src/refl/BuildOption.cs +++ b/src/refl/BuildOption.cs @@ -32,7 +32,7 @@ namespace refl [Option('h', "help", HelpText = "Display this help message.")] public bool Help { get; set; } = false; - static string InputFile = "cpp_input.h"; + static string InputFile = "/cpp_input.h"; static CppParserOptions MakeParserOptions(CmdBuildOption opt) { var parse = new CppParserOptions @@ -64,8 +64,18 @@ namespace refl StringBuilder code = new StringBuilder(); string fileContent = File.ReadAllText(file_path); code.AppendLine(fileContent.Replace("#include", "//#include")); - File.WriteAllText(InputFile, code.ToString()); - return InputFile; + // 获取 Roaming AppData 目录 + string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + string myAppPath = Path.Combine(appDataPath, "zengine"); + + // 如果目录不存在,则创建它 + if (!Directory.Exists(myAppPath)) + { + Directory.CreateDirectory(myAppPath); + } + string path = myAppPath + InputFile; + File.WriteAllText(path, code.ToString()); + return path; } public static int CMD_CheckBuildOption(CmdBuildOption opt) { @@ -108,10 +118,6 @@ namespace refl { Console.WriteLine("gen success!"); } - else - { - File.Delete(InputFile); - } return 0; } }