|
1 | 1 | #include <stdio.h>
|
2 | 2 | #include <string.h>
|
3 | 3 | #include <time.h>
|
| 4 | +#include <filesystem> |
4 | 5 | #include <functional>
|
5 | 6 | #include <iostream>
|
6 | 7 | #include <map>
|
@@ -1283,6 +1284,21 @@ int main(int argc, const char* argv[]) {
|
1283 | 1284 | }
|
1284 | 1285 | }
|
1285 | 1286 |
|
| 1287 | + // create directory if not exists |
| 1288 | + { |
| 1289 | + namespace fs = std::filesystem; |
| 1290 | + const fs::path out_path = params.output_path; |
| 1291 | + if (const fs::path out_dir = out_path.parent_path(); !out_dir.empty()) { |
| 1292 | + std::error_code ec; |
| 1293 | + fs::create_directories(out_dir, ec); // OK if already exists |
| 1294 | + if (ec) { |
| 1295 | + fprintf(stderr, "failed to create directory '%s': %s\n", |
| 1296 | + out_dir.string().c_str(), ec.message().c_str()); |
| 1297 | + return 1; |
| 1298 | + } |
| 1299 | + } |
| 1300 | + } |
| 1301 | + |
1286 | 1302 | std::string base_path;
|
1287 | 1303 | std::string file_ext;
|
1288 | 1304 | std::string file_ext_lower;
|
|
0 commit comments