mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 06:13:51 -07:00
Merge pull request #687 from mwalker33/Settings-2
Settings - full path name
This commit is contained in:
commit
5c511d35a9
2 changed files with 35 additions and 17 deletions
|
@ -23,7 +23,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "cmdparser.h"
|
#include "cmdparser.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
// #include <unistd.h>
|
||||||
|
#include <proxmark3.h>
|
||||||
|
|
||||||
//#include "proxgui.h"
|
//#include "proxgui.h"
|
||||||
//extern void SetWindowsPosition (void);
|
//extern void SetWindowsPosition (void);
|
||||||
|
@ -31,25 +32,27 @@ static int CmdHelp(const char *Cmd);
|
||||||
static int setCmdHelp(const char *Cmd);
|
static int setCmdHelp(const char *Cmd);
|
||||||
|
|
||||||
// Load all settings into memory (struct)
|
// Load all settings into memory (struct)
|
||||||
static char* prefGetFilename (void) {
|
|
||||||
/*
|
|
||||||
static char Buffer[FILENAME_MAX+sizeof(preferencesFilename)+2] = {0};
|
|
||||||
char PATH[FILENAME_MAX] = {0};
|
|
||||||
|
|
||||||
getcwd(PATH, sizeof(PATH));
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
snprintf (Buffer,sizeof(Buffer)-1,"%s\\%s",PATH,preferencesFilename);
|
#include <direct.h>
|
||||||
|
#define GetCurrentDir _getcwd
|
||||||
#else
|
#else
|
||||||
snprintf (Buffer,sizeof(Buffer)-1,"%s/%s",PATH,preferencesFilename);
|
#include <unistd.h>
|
||||||
|
#define GetCurrentDir getcwd
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return Buffer;
|
static char* prefGetFilename (void) {
|
||||||
*/
|
char *Path;
|
||||||
|
|
||||||
|
if (searchHomeFilePath(&Path,preferencesFilename,false) == PM3_SUCCESS)
|
||||||
|
return Path;
|
||||||
|
else
|
||||||
return preferencesFilename;
|
return preferencesFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
int preferences_load (void) {
|
int preferences_load (void) {
|
||||||
|
|
||||||
|
PrintAndLogEx(INFO,"Looking for preferences...");
|
||||||
|
|
||||||
// Set all defaults
|
// Set all defaults
|
||||||
session.client_debug_level = OFF;
|
session.client_debug_level = OFF;
|
||||||
session.window_changed = false;
|
session.window_changed = false;
|
||||||
|
@ -554,6 +557,7 @@ static int CmdPrefShow (const char *Cmd) {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrintAndLogEx(NORMAL," Preference file........ "_GREEN_("%s"),prefGetFilename());
|
||||||
showEmojiState (prefShowNone);
|
showEmojiState (prefShowNone);
|
||||||
showColorState (prefShowNone);
|
showColorState (prefShowNone);
|
||||||
// showPlotPosState ();
|
// showPlotPosState ();
|
||||||
|
|
|
@ -29,8 +29,16 @@
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <direct.h>
|
||||||
|
#define GetCurrentDir _getcwd
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#define GetCurrentDir getcwd
|
||||||
|
#endif
|
||||||
|
|
||||||
// Used to enable/disable use of preferences json file
|
// Used to enable/disable use of preferences json file
|
||||||
// #define USE_PREFERENCE_FILE
|
#define USE_PREFERENCE_FILE
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
@ -391,16 +399,22 @@ static void set_my_executable_path(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *my_user_directory = NULL;
|
static const char *my_user_directory = NULL;
|
||||||
|
static char _cwd_Buffer [FILENAME_MAX] = {0};
|
||||||
|
|
||||||
const char *get_my_user_directory(void) {
|
const char *get_my_user_directory(void) {
|
||||||
return my_user_directory;
|
return my_user_directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_my_user_directory(void) {
|
static void set_my_user_directory(void) {
|
||||||
my_user_directory = getenv("HOME");
|
my_user_directory = getenv("HOME");
|
||||||
|
|
||||||
// if not found, default to current directory
|
// if not found, default to current directory
|
||||||
if (my_user_directory == NULL)
|
if (my_user_directory == NULL) {
|
||||||
my_user_directory = ".";
|
my_user_directory = GetCurrentDir ( _cwd_Buffer,sizeof( _cwd_Buffer));
|
||||||
|
// change all slashs to / (windows should not care...
|
||||||
|
for (int i = 0; i < strlen(_cwd_Buffer); i++)
|
||||||
|
if (_cwd_Buffer[i] == '\\') _cwd_Buffer[i] = '/';
|
||||||
|
// my_user_directory = ".";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_help(bool showFullHelp, char *exec_name) {
|
static void show_help(bool showFullHelp, char *exec_name) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue