comparison rogue3/save.c @ 2:e676d52b5d09

Prevent changing name or save file when using system savedir
author edwarj4
date Wed, 14 Oct 2009 11:21:33 +0000
parents b4856d4d4c4e
children 09da55b986ca
comparison
equal deleted inserted replaced
1:b4856d4d4c4e 2:e676d52b5d09
49 if (c == 'y' || c == 'Y') 49 if (c == 'y' || c == 'Y')
50 { 50 {
51 msg("File name: %s", file_name); 51 msg("File name: %s", file_name);
52 goto gotfile; 52 goto gotfile;
53 } 53 }
54 if (use_savedir)
55 return FALSE;
56 /* because you're not allowed to change the savefile if
57 you're using the system savedir! */
54 } 58 }
55 59
56 do 60 do
57 { 61 {
58 msg("File name: "); 62 msg("File name: ");
64 return FALSE; 68 return FALSE;
65 } 69 }
66 strcpy(file_name, buf); 70 strcpy(file_name, buf);
67 gotfile: 71 gotfile:
68 if ((savef = fopen(file_name, "w")) == NULL) 72 if ((savef = fopen(file_name, "w")) == NULL)
73 {
69 msg(strerror(errno)); /* fake perror() */ 74 msg(strerror(errno)); /* fake perror() */
75 if (use_savedir)
76 return FALSE;
77 }
70 } while (savef == NULL); 78 } while (savef == NULL);
71 79
72 /* 80 /*
73 * write out encrpyted file (after a stat) 81 * write out encrypted file (after a stat)
74 * The fwrite is to force allocation of the buffer before the write 82 * The fwrite is to force allocation of the buffer before the write
75 */ 83 */
76 if (save_file(savef) != 0) 84 if (save_file(savef) != 0)
77 { 85 {
78 msg("Save game failed!"); 86 msg("Save game failed!");