Mercurial > hg > early-roguelike
comparison xrogue/save.c @ 137:443c8bd3e290
xrogue: restrict changes to the save file location.
When using the -n option, disallow changing file_name or whoami via
options or dialogs.
author | John "Elwin" Edwards |
---|---|
date | Sat, 02 May 2015 07:31:14 -0400 |
parents | 1fbdefa82533 |
children | 6e6fb0955095 |
comparison
equal
deleted
inserted
replaced
136:1fbdefa82533 | 137:443c8bd3e290 |
---|---|
41 * get file name | 41 * get file name |
42 */ | 42 */ |
43 mpos = 0; | 43 mpos = 0; |
44 if (file_name[0] != '\0') | 44 if (file_name[0] != '\0') |
45 { | 45 { |
46 msg("Save file (%s)? ", file_name); | 46 if (use_savedir) |
47 msg("Save game? "); | |
48 else | |
49 msg("Save file (%s)? ", file_name); | |
47 do | 50 do |
48 { | 51 { |
49 c = wgetch(cw); | 52 c = wgetch(cw); |
50 if (c == ESC) return(0); | 53 if (c == ESC) return(0); |
51 } while (c != 'n' && c != 'N' && c != 'y' && c != 'Y'); | 54 } while (c != 'n' && c != 'N' && c != 'y' && c != 'Y'); |
57 } | 60 } |
58 } | 61 } |
59 else | 62 else |
60 goto gotfile; /* must save to file restored from */ | 63 goto gotfile; /* must save to file restored from */ |
61 | 64 |
65 if (use_savedir) { | |
66 msg(""); | |
67 return FALSE; | |
68 } | |
69 | |
62 do | 70 do |
63 { | 71 { |
64 msg("File name: "); | 72 msg("File name: "); |
65 mpos = 0; | 73 mpos = 0; |
66 buf[0] = '\0'; | 74 buf[0] = '\0'; |
70 return FALSE; | 78 return FALSE; |
71 } | 79 } |
72 strcpy(file_name, buf); | 80 strcpy(file_name, buf); |
73 gotfile: | 81 gotfile: |
74 | 82 |
75 if ((savef = fopen(file_name, "wb")) == NULL) | 83 if ((savef = fopen(file_name, "wb")) == NULL) { |
76 msg(strerror(errno)); | 84 msg(strerror(errno)); |
85 if (use_savedir) | |
86 return FALSE; | |
87 } | |
77 } while (savef == NULL); | 88 } while (savef == NULL); |
78 | 89 |
79 msg(""); | 90 msg(""); |
80 /* | 91 /* |
81 * write out encrpyted file | 92 * write out encrpyted file |