comparison src/gui.c @ 9:d2cd8c5672fa

Increase filename limit 256 bytes is enough for anybody
author Paper <mrpapersonic@gmail.com>
date Wed, 26 Jan 2022 23:12:41 -0500
parents d1e5b8390cd3
children 423aa3429d21
comparison
equal deleted inserted replaced
8:9d862edfd3cc 9:d2cd8c5672fa
9 #define LISTBOX 2 9 #define LISTBOX 2
10 #define SAVE_FILE_BUTTON 3 10 #define SAVE_FILE_BUTTON 3
11 11
12 HWND hWndListBox, hWndComboBox; 12 HWND hWndListBox, hWndComboBox;
13 int16_t version = 11, type = 1; /* type: 0 is vf, 1 is veg */ 13 int16_t version = 11, type = 1; /* type: 0 is vf, 1 is veg */
14 char* file_name = " "; /* initialize as a space, a filename cannot literally just be a space */ 14 char* file_name = " "; /* initialize as a space, a (windows) filename can't just be a space */
15 15
16 void set_data(unsigned char magic[], uint16_t version, FILE* target) { 16 void set_data(unsigned char magic[], uint16_t version, FILE* target) {
17 int i; 17 int i;
18 fseek(target, 0x46, SEEK_SET); 18 fseek(target, 0x46, SEEK_SET);
19 fputc(version, target); 19 fputc(version, target);
62 fclose(file); 62 fclose(file);
63 } 63 }
64 64
65 char* open_file(HWND hWnd) { 65 char* open_file(HWND hWnd) {
66 OPENFILENAME ofn; 66 OPENFILENAME ofn;
67 char filename[127]; 67 char filename[256];
68 68
69 ZeroMemory(&ofn, sizeof(OPENFILENAME)); 69 ZeroMemory(&ofn, sizeof(OPENFILENAME));
70 ofn.lStructSize = sizeof(OPENFILENAME); 70 ofn.lStructSize = sizeof(OPENFILENAME);
71 ofn.hwndOwner = hWnd; 71 ofn.hwndOwner = hWnd;
72 ofn.lpstrFile = filename; 72 ofn.lpstrFile = filename;
73 ofn.lpstrFile[0] = '\0'; 73 ofn.lpstrFile[0] = '\0';
74 ofn.nMaxFile = 127; 74 ofn.nMaxFile = 256;
75 ofn.lpstrFilter = "Project files\0*.veg;*.vf\0All files\0*.*\0"; 75 ofn.lpstrFilter = "Project files\0*.veg;*.vf\0All files\0*.*\0";
76 ofn.nFilterIndex = 1; 76 ofn.nFilterIndex = 1;
77 77
78 GetOpenFileName(&ofn); 78 GetOpenFileName(&ofn);
79 79
86 if (strcmp(input_file, " ") == 0) { 86 if (strcmp(input_file, " ") == 0) {
87 MessageBoxW(hWnd, L"Please open a file first!", L"Invalid input file!", MB_ICONEXCLAMATION); 87 MessageBoxW(hWnd, L"Please open a file first!", L"Invalid input file!", MB_ICONEXCLAMATION);
88 return; 88 return;
89 } 89 }
90 OPENFILENAME ofn; 90 OPENFILENAME ofn;
91 char output_file[127]; 91 char output_file[256];
92 92
93 ZeroMemory(&ofn, sizeof(OPENFILENAME)); 93 ZeroMemory(&ofn, sizeof(OPENFILENAME));
94 ofn.lStructSize = sizeof(OPENFILENAME); 94 ofn.lStructSize = sizeof(OPENFILENAME);
95 ofn.hwndOwner = hWnd; 95 ofn.hwndOwner = hWnd;
96 ofn.lpstrFile = output_file; 96 ofn.lpstrFile = output_file;
97 ofn.lpstrFile[0] = '\0'; 97 ofn.lpstrFile[0] = '\0';
98 ofn.nMaxFile = 127; 98 ofn.nMaxFile = 256;
99 ofn.lpstrFilter = "Project files\0*.veg\0All files\0*.*\0"; 99 ofn.lpstrFilter = "Project files\0*.veg\0All files\0*.*\0";
100 ofn.nFilterIndex = 1; 100 ofn.nFilterIndex = 1;
101 101
102 GetSaveFileName(&ofn); 102 GetSaveFileName(&ofn);
103 103