MCPcopy Create free account
hub / github.com/duckdb/duckdb / OpenOutputFile

Method OpenOutputFile

tools/shell/shell.cpp:1323–1339  ·  view source on GitHub ↗

** 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". */

Source from the content-addressed store, hash-verified

1321** filename is "off".
1322*/
1323FILE *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
1341string ShellState::GetSystemPager() {
1342 const char *duckdb_pager = getenv("DUCKDB_PAGER");

Callers 1

ToggleLogFunction · 0.80

Calls 1

c_strMethod · 0.80

Tested by

no test coverage detected