From bb6755a72ebd8076b315e3f3d697518a4e812953 Mon Sep 17 00:00:00 2001 From: emteere <47253321+emteere@users.noreply.github.com> Date: Thu, 13 Apr 2023 23:04:00 +0000 Subject: [PATCH] GP-2308 Fix for cparser .out file not in CWD --- .../ghidra/app/util/cparser/C/CParserUtils.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/C/CParserUtils.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/C/CParserUtils.java index 076df67d9d..c28865e49c 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/C/CParserUtils.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/C/CParserUtils.java @@ -531,9 +531,19 @@ public class CParserUtils { cpp.addIncludePaths(includePaths); PrintStream os = System.out; - String fName = dtMgr.getName().replace(".gdt","")+"_CParser.out"; + + String fName = dtMgr.getName(); + + // make a path to tmpdir with name of data type manager + String path = System.getProperty("java.io.tmpdir") + File.pathSeparator + fName; + // if file data type manager, use path to .gdt file + if (dtMgr instanceof FileDataTypeManager) { + path = ((FileDataTypeManager) dtMgr).getPath(); + } + path = path + "_CParser.out"; + try { - os = new PrintStream(new FileOutputStream(fName)); + os = new PrintStream(new FileOutputStream(path)); } catch (FileNotFoundException e2) { Msg.error(CParserUtils.class, "Unexpected Exception: " + e2.getMessage(), e2); }