MCPcopy Create free account
hub / github.com/avast/retdec-idaplugin / getInputPath

Function getInputPath

src/idaplugin/utils.cpp:66–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66std::string getInputPath()
67{
68 char buff[MAXSTR];
69
70 get_root_filename(buff, sizeof(buff));
71 std::string inName = buff;
72
73 get_input_file_path(buff, sizeof(buff));
74 std::string inPath = buff;
75
76 std::string idb = get_path(PATH_TYPE_IDB);
77 std::string id0 = get_path(PATH_TYPE_ID0);
78 std::string workDir;
79 if (!idb.empty())
80 {
81 fs::path fsIdb(idb);
82 workDir = fsIdb.parent_path().string();
83 }
84 else if (!id0.empty())
85 {
86 fs::path fsId0(id0);
87 workDir = fsId0.parent_path().string();
88 }
89 if (workDir.empty())
90 {
91 return std::string();
92 }
93
94 if (!fs::exists(inPath))
95 {
96 fs::path fsWork(workDir);
97 fsWork.append(inName);
98 inPath = fsWork.string();
99
100 if (!fs::exists(inPath))
101 {
102 char *tmp = ask_file( ///< Returns: file name
103 false, ///< bool for_saving
104 nullptr, ///< const char *default_answer
105 "%s", ///< const char *format
106 "Input binary to decompile"
107 );
108
109 if (tmp == nullptr)
110 {
111 return std::string();
112 }
113 if (!fs::exists(std::string(tmp)))
114 {
115 return std::string();
116 }
117
118 inPath = tmp;
119 }
120 }
121
122 return inPath;
123}

Callers 3

fullDecompilationMethod · 0.85
isRelocatableFunction · 0.85
generateHeaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected