Create default r0ket.cfg if missing

This commit is contained in:
Stefan `Sec` Zehl 2011-07-17 02:09:48 +02:00
parent 5f0995f1fe
commit 5574ca2cdc
1 changed files with 29 additions and 2 deletions

View File

@ -28,10 +28,37 @@ int lcdInitConfig(){
lcdPrint("open:");
lcdPrintln(f_get_rc_string(res));
if(res){
lcdPrintln("r0ket.cfg missing!");
lcdPrintln("new r0ket.cfg...");
res=f_open(&file[0], "r0ket.cfg", FA_OPEN_ALWAYS|FA_WRITE);
lcdPrint("create:");
lcdPrintln(f_get_rc_string(res));
if(res){
return 1;
};
buf[0]='0';
buf[1]='0';
res = f_write(&file[0], buf, 2, &readbytes);
lcdPrint("write:");
lcdPrintln(f_get_rc_string(res));
if(res){
return 1;
};
lcdPrint("wrote:");
lcdPrintInt(readbytes);
lcdPrintln("b");
res=f_close(&file[0]);
lcdPrint("close:");
lcdPrintln(f_get_rc_string(res));
if(res){
return 1;
};
return 2; // created. Still show screen
};
for(int i=0;i<CONFIGLEN;i++)
buf[i]=0;