Changeset 1106
- Timestamp:
- 01/09/09 07:55:46 (9 hours ago)
- Files:
-
- trunk/src/cmd4.c (modified) (1 diff)
- trunk/src/death.c (modified) (2 diffs)
- trunk/src/externs.h (modified) (1 diff)
- trunk/src/files.c (modified) (2 diffs)
- trunk/src/util.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cmd4.c
r1103 r1106 2021 2021 else if (ke.key == 'f') 2022 2022 { 2023 char ftmp[80]; 2024 2025 strnfmt(ftmp, sizeof ftmp, "%s.txt", op_ptr->base_name); 2026 2027 if (get_string("File name: ", ftmp, 80)) 2023 char buf[1024]; 2024 char fname[80]; 2025 2026 strnfmt(fname, sizeof fname, "%s.txt", op_ptr->base_name); 2027 2028 if (get_file(fname, buf, sizeof buf)) 2028 2029 { 2029 if (ftmp[0] && (ftmp[0] != ' ')) 2030 { 2031 if (file_character(ftmp, FALSE)) 2032 msg_print("Character dump failed!"); 2033 else 2034 msg_print("Character dump successful."); 2035 } 2030 if (file_character(buf, FALSE) != 0) 2031 msg_print("Character dump failed!"); 2032 else 2033 msg_print("Character dump successful."); 2036 2034 } 2037 2035 } trunk/src/death.c
r966 r1106 180 180 static void death_file(void *unused, const char *title) 181 181 { 182 char buf[1024]; 182 183 char ftmp[80]; 184 185 (void)unused; 186 (void)title; 187 183 188 strnfmt(ftmp, sizeof(ftmp), "%s.txt", op_ptr->base_name); 184 189 185 (void)unused; 186 (void)title; 187 188 if (!get_string("File name: ", ftmp, sizeof(ftmp))) 189 return; 190 191 if (ftmp[0] && (ftmp[0] != ' ')) 190 if (get_file(ftmp, buf, sizeof buf)) 192 191 { 193 192 errr err; … … 195 194 /* Dump a character file */ 196 195 screen_save(); 197 err = file_character( ftmp, FALSE);196 err = file_character(buf, FALSE); 198 197 screen_load(); 199 198 trunk/src/externs.h
r1067 r1106 626 626 extern s16b get_quantity(cptr prompt, int max); 627 627 extern bool get_check(cptr prompt); 628 bool (*get_file)(const char *suggested_name, char *path, size_t len); 628 629 extern bool get_com(cptr prompt, char *command); 629 630 extern bool get_com_ex(cptr prompt, ui_event_data *command); trunk/src/files.c
r1078 r1106 1909 1909 * and trigger its usage from various places in the code. 1910 1910 */ 1911 errr file_character(c ptr name, bool full)1911 errr file_character(const char *path, bool full) 1912 1912 { 1913 1913 int i, x, y; … … 1928 1928 (void)full; 1929 1929 1930 /* Build the filename */1931 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);1932 1933 /* Check if the file currently exists */1934 if (file_exists(buf))1935 {1936 char out_val[160];1937 1938 /* Build query */1939 strnfmt(out_val, sizeof(out_val), "Replace existing file %s? ", buf);1940 1941 /* Ask */1942 if (!get_check(out_val))1943 return -1;1944 }1945 1930 1946 1931 /* Open the file for writing */ 1947 fp = file_open( buf, MODE_WRITE, FTYPE_TEXT);1932 fp = file_open(path, MODE_WRITE, FTYPE_TEXT); 1948 1933 if (!fp) return (-1); 1949 1934 trunk/src/util.c
r1103 r1106 2620 2620 2621 2621 2622 /** 2623 * Text-native way of getting a filename. 2624 */ 2625 bool get_file_text(const char *suggested_name, char *path, size_t len) 2626 { 2627 char buf[160]; 2628 2629 /* Get filename */ 2630 my_strcpy(buf, suggested_name, sizeof buf); 2631 if (!get_string("File name: ", buf, sizeof buf)) return FALSE; 2632 2633 /* Make sure it's actually a filename */ 2634 if (buf[0] == '\0' || buf[0] == ' ') return FALSE; 2635 2636 /* Build the path */ 2637 path_build(path, len, ANGBAND_DIR_USER, buf); 2638 2639 /* Check if it already exists */ 2640 if (file_exists(buf)) 2641 { 2642 char buf2[160]; 2643 strnfmt(buf2, sizeof(buf2), "Replace existing file %s?", buf); 2644 2645 if (get_check(buf2) == FALSE) 2646 return FALSE; 2647 } 2648 2649 return TRUE; 2650 } 2651 2652 2653 2654 2655 /** 2656 * Get a pathname to save a file to, given the suggested name. Returns the 2657 * result in "path". 2658 */ 2659 bool (*get_file)(const char *suggested_name, char *path, size_t len) = get_file_text; 2660 2661 2662 2663 2622 2664 /* 2623 2665 * Prompts for a keypress
