mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-25 23:55:25 -07:00
Update preferences.c
This commit is contained in:
parent
0b360d4dc0
commit
b72123a093
1 changed files with 13 additions and 11 deletions
|
@ -23,6 +23,8 @@
|
|||
#include <string.h>
|
||||
#include "cmdparser.h"
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
//#include "proxgui.h"
|
||||
//extern void SetWindowsPosition (void);
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
@ -30,15 +32,15 @@ static int setCmdHelp(const char *Cmd);
|
|||
|
||||
// Load all settings into memory (struct)
|
||||
static char* prefGetFilename (void) {
|
||||
static char Buffer[500];
|
||||
static char Buffer[500+sizeof(preferencesFilename)+2] = {0};
|
||||
char PATH[500] = {0};
|
||||
|
||||
getcwd(Buffer, sizeof(Buffer));
|
||||
getcwd(PATH, sizeof(PATH));
|
||||
#ifdef _WIN32
|
||||
strncat (Buffer,"\\",sizeof(Buffer)-strlen(Buffer));
|
||||
snprintf (Buffer,sizeof(Buffer)-1,"%s\\%s",PATH,preferencesFilename);
|
||||
#else
|
||||
strncat (Buffer,"/",sizeof(Buffer)-strlen(Buffer));
|
||||
snprintf (Buffer,sizeof(Buffer)-1,"%s/%s",PATH,preferencesFilename);
|
||||
#endif
|
||||
strncat (Buffer,preferencesFilename,sizeof(Buffer)-strlen(Buffer));
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
@ -76,9 +78,9 @@ int preferences_load (void) {
|
|||
// Save all settings from memory (struct) to file
|
||||
int preferences_save (void) {
|
||||
// Note sure if backup has value ?
|
||||
char backupFilename[500];
|
||||
char backupFilename[500+sizeof(preferencesFilename)+10] = {0};
|
||||
|
||||
snprintf (backupFilename,sizeof(backupFilename),"%s.bak",prefGetFilename());
|
||||
snprintf (backupFilename,sizeof(backupFilename)-1,"%s.bak",prefGetFilename());
|
||||
|
||||
if (fileExists (backupFilename)) {
|
||||
if (remove (backupFilename) != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue