diff --git a/firmware/applications/final/nickname.c b/firmware/applications/final/nickname.c index a0985ef..9f62162 100644 --- a/firmware/applications/final/nickname.c +++ b/firmware/applications/final/nickname.c @@ -56,9 +56,9 @@ void simpleNickname(void) { /**************************************************************************/ void init_nick(void){ - readFile("nick.cfg",GLOBAL(nickname),MAXNICK); - readFile("font.cfg",GLOBAL(nickfont),FILENAMELEN); - readFile("l0nick.cfg",GLOBAL(nickl0),FILENAMELEN); + readTextFile("nick.cfg",GLOBAL(nickname),MAXNICK); + readTextFile("font.cfg",GLOBAL(nickfont),FILENAMELEN); + readTextFile("l0nick.cfg",GLOBAL(nickl0),FILENAMELEN); }; //# MENU nick editNick diff --git a/firmware/filesystem/util.c b/firmware/filesystem/util.c index e425852..5fd246a 100644 --- a/firmware/filesystem/util.c +++ b/firmware/filesystem/util.c @@ -39,17 +39,26 @@ int readFile(char * filename, char * data, int len){ return -1; }; - res = f_read(&file, data, len-1, &readbytes); + res = f_read(&file, data, len, &readbytes); if(res){ return -1; }; f_close(&file); - data[readbytes]=0; return readbytes; }; +int readTextFile(char * filename, char * data, int len){ + UINT readbytes; + + readbytes=readFile(filename,data,len-1); + if(len>=0) + data[readbytes]=0; + return readbytes; +}; + + int writeFile(char * filename, char * data, int len){ FIL file; UINT writebytes;