File tree 2 files changed +18
-2
lines changed 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ auto main(
45
45
return EXIT_FAILURE;
46
46
}
47
47
48
+ if (std::filesystem::exists (flag_cwd)) {
49
+ std::filesystem::current_path (flag_cwd);
50
+ }
51
+
48
52
// For each Cpp2 source file
49
53
int exit_status = EXIT_SUCCESS;
50
54
for (auto const & arg : cmdline.arguments ())
Original file line number Diff line number Diff line change @@ -176,6 +176,15 @@ static cmdline_processor::register_flag cmd_cpp1_filename(
176
176
[](std::string const & name) { flag_cpp1_filename = name; }
177
177
);
178
178
179
+ static auto flag_cwd = std::filesystem::path{};;
180
+ static cpp2::cmdline_processor::register_flag cmd_cwd (
181
+ 9 ,
182
+ " cwd directory" ,
183
+ " Change current working directory" ,
184
+ nullptr ,
185
+ [](std::string const & path) { flag_cwd = { path }; }
186
+ );
187
+
179
188
static auto flag_print_colon_errors = false ;
180
189
static cmdline_processor::register_flag cmd_print_colon_errors (
181
190
9 ,
@@ -1297,8 +1306,11 @@ class cppfront
1297
1306
1298
1307
// Now we'll open the Cpp1 file
1299
1308
auto cpp1_filename = sourcefile.substr (0 , std::ssize (sourcefile) - 1 );
1300
- if (!flag_cpp1_filename.empty ()) {
1301
- cpp1_filename = flag_cpp1_filename; // use override if present
1309
+ if (!flag_cpp1_filename.empty ()) { // use override if present
1310
+ cpp1_filename = flag_cpp1_filename;
1311
+ }
1312
+ else if (!flag_cwd.empty ()) { // strip leading path if cwd was explicitly set
1313
+ cpp1_filename = std::filesystem::path (cpp1_filename).filename ().string ();
1302
1314
}
1303
1315
1304
1316
printer.open (
You can’t perform that action at this time.
0 commit comments