git @ Cat's Eye Technologies linapple / 1a37c9d
Restore chunk of disabled code. Note caveat if you plan on enabling. Chris Pressey 4 years ago
1 changed file(s) with 44 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
178178
179179 void RegSaveKeyValue(char * NKey, char * NValue)
180180 {
181 #ifdef REGISTRY_WRITEABLE
182 char MyStr[BUFSIZE];
183 char line[BUFSIZE];
184 char templine[BUFSIZE];
185 char *sztmp;
186 FILE * tempf = tmpfile(); // open temp file
187 // FILE * tempf = fopen("linapple-temp.conf", "w+");
188 if(!tempf) return;
189 snprintf(MyStr, BUFSIZE, "\t%s =\t%s\n", NKey, NValue); // prepare string
190 fseek(registry, 0, SEEK_SET); //
191 bool found = false;
192 while(fgets(line, BUFSIZE, registry))
193 {
194 // printf("---1:%s", line);
195 strcpy(templine, line);
196 if(ReturnKeyValue(templine, &sztmp, &NValue) && !(strcmp(sztmp, NKey)))
197 {
198 fputs(MyStr, tempf);
199 found = true;
200 // printf("------ !!!!!!!!!!!!!!!! I FOUND IT!!!!!\n\n");
201 }
202 else fputs(line, tempf);
203 // printf("---2:%s", line);
204 }
205 if(!found) fputs(MyStr, tempf);
206 // now swap tempf and registry
207 fclose(registry);
208 fflush(tempf);
209 fseek(tempf, 0, SEEK_SET);
210 // fclose(tempf);
211 // return;
212 // FIXME if you enable this code, you will need to call config.GetRegistryPath() here instead!
213 registry = fopen(REGISTRY, "w+t"); // erase if been
214 while(fgets(line, BUFSIZE, tempf)) {
215 fputs(line, registry);
216 // printf("---Saving Line:%s", line);
217 }
218 fflush(registry);
219 fclose(tempf);
220 // fflush(registry); // for chance... --bb
221 // do not close registry, it should be open while emu working...
222 #else
223 printf("Attempt to set '%s' to '%s' ignored (registry is read-only)\n", NKey, NValue);
224 #endif /* REGISTRY_WRITEABLE */
181225 printf("Attempt to set '%s' to '%s' ignored (registry is read-only)\n", NKey, NValue);
182226 }
183227