Display the file named str. Complain about missing files iff complain is TRUE. */
| 962 | iff complain is TRUE. |
| 963 | */ |
| 964 | void |
| 965 | mswin_display_file(const char *filename, BOOLEAN_P must_exist) |
| 966 | { |
| 967 | dlb *f; |
| 968 | TCHAR wbuf[BUFSZ]; |
| 969 | |
| 970 | logDebug("mswin_display_file(%s, %d)\n", filename, must_exist); |
| 971 | |
| 972 | f = dlb_fopen(filename, RDTMODE); |
| 973 | if (!f) { |
| 974 | if (must_exist) { |
| 975 | TCHAR message[90]; |
| 976 | _stprintf(message, TEXT("Warning! Could not find file: %s\n"), |
| 977 | NH_A2W(filename, wbuf, sizeof(wbuf))); |
| 978 | MessageBox(GetNHApp()->hMainWnd, message, TEXT("ERROR"), |
| 979 | MB_OK | MB_ICONERROR); |
| 980 | } |
| 981 | } else { |
| 982 | winid text; |
| 983 | char line[LLEN]; |
| 984 | |
| 985 | text = mswin_create_nhwindow(NHW_TEXT); |
| 986 | |
| 987 | while (dlb_fgets(line, LLEN, f)) { |
| 988 | size_t len; |
| 989 | len = strlen(line); |
| 990 | if (line[len - 1] == '\n') |
| 991 | line[len - 1] = '\x0'; |
| 992 | mswin_putstr(text, ATR_NONE, line); |
| 993 | } |
| 994 | (void) dlb_fclose(f); |
| 995 | |
| 996 | mswin_display_nhwindow(text, 1); |
| 997 | mswin_destroy_nhwindow(text); |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | /* Start using window as a menu. You must call start_menu() |
| 1002 | before add_menu(). After calling start_menu() you may not |
nothing calls this directly
no test coverage detected