** Try to open an output file. The names "stdout" and "stderr" are ** recognized and do the right thing. NULL is returned if the output ** filename is "off". */
| 1321 | ** filename is "off". |
| 1322 | */ |
| 1323 | FILE *ShellState::OpenOutputFile(const char *zFile, int bTextMode) { |
| 1324 | FILE *f = nullptr; |
| 1325 | if (strcmp(zFile, "stdout") == 0) { |
| 1326 | f = stdout; |
| 1327 | } else if (strcmp(zFile, "stderr") == 0) { |
| 1328 | f = stderr; |
| 1329 | } else if (strcmp(zFile, "off") == 0) { |
| 1330 | f = 0; |
| 1331 | } else { |
| 1332 | const string expanded_path = duckdb::FileSystem::ExpandPath(zFile, /*opener=*/nullptr); |
| 1333 | f = fopen(expanded_path.c_str(), bTextMode ? "w" : "wb"); |
| 1334 | if (f == 0) { |
| 1335 | PrintF(PrintOutput::STDERR, "Error: cannot open \"%s\"\n", zFile); |
| 1336 | } |
| 1337 | } |
| 1338 | return f; |
| 1339 | } |
| 1340 | |
| 1341 | string ShellState::GetSystemPager() { |
| 1342 | const char *duckdb_pager = getenv("DUCKDB_PAGER"); |