/* * formatted text-only file prompt */ int CVmConsole::askfile(VMG_ const char *prompt, size_t prompt_len, char *reply, size_t replen, int dialog_type, os_filetype_t file_type, int /*bypass_script*/) { int result; size_t prompt_ui_len; char prompt_ui[256]; char fname[OSFNMAX]; /* flush any pending output */ flush(vmg_ VM_NL_INPUT); /* translate the prompt to the local UI character set */ prompt_ui_len = G_cmap_to_ui->map_utf8(prompt_ui, sizeof(prompt_ui) - 1, prompt, prompt_len, 0); /* null-terminate the translated prompt */ prompt_ui[prompt_ui_len] = '\0'; /* let the system handle it */ result = os_askfile(prompt, fname, sizeof(fname), dialog_type, file_type); /* if we were successful, translate the filename to UTF-8 */ if (result == OS_AFE_SUCCESS) { char *dst; size_t dstlen; /* * The result string is in the local UI character set, so we * must translate it to UTF-8 for the caller. Note that we * reserve one byte of the result buffer for the null * terminator. */ dst = reply; dstlen = replen - 1; G_cmap_from_ui->map(&dst, &dstlen, fname, strlen(fname)); /* null-terminate the result */ *dst = '\0'; } /* return the result */ return result; }
/* * formatted text-only file prompt */ int tio_askfile(const char *prompt, char *reply, int replen, int prompt_type, os_filetype_t file_type) { /* let the OS layer handle it */ return os_askfile(prompt, reply, replen, prompt_type, file_type); }