mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-24 15:15:39 -07:00
Test code for full path
This commit is contained in:
parent
a1976fd6fe
commit
0b43252a02
2 changed files with 54 additions and 6 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,6 +32,14 @@ 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)
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <direct.h>
|
||||||
|
#define GetCurrentDir _getcwd
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#define GetCurrentDir getcwd
|
||||||
|
#endif
|
||||||
|
|
||||||
static char* prefGetFilename (void) {
|
static char* prefGetFilename (void) {
|
||||||
/*
|
/*
|
||||||
static char Buffer[FILENAME_MAX+sizeof(preferencesFilename)+2] = {0};
|
static char Buffer[FILENAME_MAX+sizeof(preferencesFilename)+2] = {0};
|
||||||
|
@ -45,7 +54,24 @@ static char* prefGetFilename (void) {
|
||||||
|
|
||||||
return Buffer;
|
return Buffer;
|
||||||
*/
|
*/
|
||||||
return preferencesFilename;
|
static char Buffer [FILENAME_MAX] = {0};
|
||||||
|
char *Path;
|
||||||
|
|
||||||
|
// int searchHomeFilePath(char **foundpath, const char *filename, bool create_home);
|
||||||
|
if (searchHomeFilePath(&Path,preferencesFilename,false) == PM3_SUCCESS) {
|
||||||
|
snprintf(Buffer,sizeof(Buffer)-1,"%s",Path);
|
||||||
|
} else {
|
||||||
|
snprintf(Buffer,sizeof(Buffer)-1,"%s",preferencesFilename);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//printf ("%s [%s]\n",Buffer,get_my_user_directory() );
|
||||||
|
|
||||||
|
// GetCurrentDir (Buffer,sizeof(Buffer));
|
||||||
|
// printf ("%s\n",Buffer, );
|
||||||
|
|
||||||
|
return Buffer;
|
||||||
|
//return preferencesFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
int preferences_load (void) {
|
int preferences_load (void) {
|
||||||
|
|
|
@ -29,8 +29,20 @@
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
|
||||||
|
// mwalker33 test code
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <direct.h>
|
||||||
|
#define GetCurrentDir _getcwd
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#define GetCurrentDir getcwd
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// end test code
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
|
@ -392,15 +404,25 @@ static void set_my_executable_path(void) {
|
||||||
|
|
||||||
static const char *my_user_directory = NULL;
|
static const char *my_user_directory = NULL;
|
||||||
|
|
||||||
|
// mwalker33 test code
|
||||||
|
static char _cwd_Buffer [FILENAME_MAX] = {0};
|
||||||
|
// end test code
|
||||||
|
|
||||||
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 = ".";
|
// mwalker33 test code
|
||||||
|
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] = '/';
|
||||||
|
// end
|
||||||
|
// 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