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

Function wmain

tools/shell/shell.cpp:3289–3322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3287int main(int argc, const char **argv) {
3288#else
3289int wmain(int argc, wchar_t **wargv) {
3290 vector<string> utf8_args;
3291 utf8_args.resize(argc);
3292 vector<const char *> utf8_args_ptrs;
3293 utf8_args_ptrs.resize(argc);
3294 const char **argv = utf8_args_ptrs.data();
3295 for (int i = 0; i < argc; i++) {
3296 utf8_args[i] = ShellState::Win32UnicodeToUtf8(wargv[i]);
3297 utf8_args_ptrs[i] = utf8_args[i].c_str();
3298 }
3299#endif
3300
3301 auto &shell_state = ShellState::GetReference();
3302 int rc = 0;
3303 try {
3304 rc = RunShell(argc, argv);
3305 } catch (std::exception &ex) {
3306 rc = 1;
3307 ErrorData error(ex);
3308 fprintf(stderr, "Exited due to error: %s", error.Message().c_str());
3309 }
3310 try {
3311 // destroy shell state prior to program clean-up
3312 if (shell_state) {
3313 delete shell_state;
3314 }
3315 shell_state = nullptr;
3316 } catch (std::exception &ex) {
3317 rc = 1;
3318 ErrorData error(ex);
3319 fprintf(stderr, "Error during clean-up due to error: %s", error.Message().c_str());
3320 }
3321 return rc;
3322}

Callers

nothing calls this directly

Calls 4

RunShellFunction · 0.85
c_strMethod · 0.80
resizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected