File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,10 @@ auto main(
53
53
return EXIT_FAILURE;
54
54
}
55
55
56
+ if (std::filesystem::exists (flag_cwd)) {
57
+ std::filesystem::current_path (flag_cwd);
58
+ }
59
+
56
60
// For each Cpp2 source file
57
61
int exit_status = EXIT_SUCCESS;
58
62
for (auto const & arg : cmdline.arguments ())
Original file line number Diff line number Diff line change @@ -164,6 +164,15 @@ static cmdline_processor::register_flag cmd_cpp1_filename(
164
164
[](std::string const & name) { flag_cpp1_filename = name; }
165
165
);
166
166
167
+ static auto flag_cwd = std::filesystem::path{};
168
+ static cpp2::cmdline_processor::register_flag cmd_cwd (
169
+ 9 ,
170
+ " cwd path" ,
171
+ " Change current working directory to path" ,
172
+ nullptr ,
173
+ [](std::string const & path) { flag_cwd = { path }; }
174
+ );
175
+
167
176
static auto flag_no_exceptions = false ;
168
177
static cmdline_processor::register_flag cmd_no_exceptions (
169
178
4 ,
@@ -1245,8 +1254,14 @@ class cppfront
1245
1254
1246
1255
// Now we'll open the Cpp1 file
1247
1256
auto cpp1_filename = sourcefile.substr (0 , std::ssize (sourcefile) - 1 );
1257
+
1258
+ // Use explicit filename override if present,
1259
+ // otherwise strip leading path
1248
1260
if (!flag_cpp1_filename.empty ()) {
1249
- cpp1_filename = flag_cpp1_filename; // use override if present
1261
+ cpp1_filename = flag_cpp1_filename;
1262
+ }
1263
+ else {
1264
+ cpp1_filename = std::filesystem::path (cpp1_filename).filename ().string ();
1250
1265
}
1251
1266
1252
1267
printer.open (
You can’t perform that action at this time.
0 commit comments