mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
reintroduce _stat on mingw, needed to strip path
This commit is contained in:
parent
6e54adcb7c
commit
fcd9b42dca
1 changed files with 17 additions and 4 deletions
21
client/ui.c
21
client/ui.c
|
@ -58,9 +58,21 @@ int searchHomeFilePath(char **foundpath, const char *filename, bool create_home)
|
||||||
strcpy(path, user_path);
|
strcpy(path, user_path);
|
||||||
strcat(path, PM3_USER_DIRECTORY);
|
strcat(path, PM3_USER_DIRECTORY);
|
||||||
|
|
||||||
// Mingw: _stat fails on mangled HOME path /pm3 => C:\ProxSpace\pm3, while stat works fine
|
int result;
|
||||||
|
#ifdef _WIN32
|
||||||
|
struct _stat st;
|
||||||
|
// Mingw _stat fails if path ends with /, so let's use a stripped path
|
||||||
|
if (path[strlen(path)-1]=='/') {
|
||||||
|
path[strlen(path)-1]='\0';
|
||||||
|
result = _stat(path, &st);
|
||||||
|
path[strlen(path)]='/';
|
||||||
|
} else {
|
||||||
|
result = _stat(path, &st);
|
||||||
|
}
|
||||||
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int result = stat(path, &st);
|
result = stat(path, &st);
|
||||||
|
#endif
|
||||||
if ((result != 0) && create_home) {
|
if ((result != 0) && create_home) {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -216,7 +228,7 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||||
timenow = gmtime(&now);
|
timenow = gmtime(&now);
|
||||||
strftime(filename, sizeof(filename), PROXLOG, timenow);
|
strftime(filename, sizeof(filename), PROXLOG, timenow);
|
||||||
if (searchHomeFilePath(&my_logfile_path, filename, true) != PM3_SUCCESS) {
|
if (searchHomeFilePath(&my_logfile_path, filename, true) != PM3_SUCCESS) {
|
||||||
fprintf(stderr, "Could not create $HOME/.proxmark3/%s, no log will be recorded\n", filename);
|
fprintf(stderr, "Could not create $HOME" PM3_USER_DIRECTORY "%s, no log will be recorded\n", filename);
|
||||||
my_logfile_path = NULL;
|
my_logfile_path = NULL;
|
||||||
logging = 0;
|
logging = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -224,8 +236,9 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||||
if (logfile == NULL) {
|
if (logfile == NULL) {
|
||||||
fprintf(stderr, "Can't open logfile %s, logging disabled!\n", my_logfile_path);
|
fprintf(stderr, "Can't open logfile %s, logging disabled!\n", my_logfile_path);
|
||||||
logging = 0;
|
logging = 0;
|
||||||
|
} else {
|
||||||
|
printf("Session is logged into %s\n", my_logfile_path);
|
||||||
}
|
}
|
||||||
printf("Session is logged into %s\n", my_logfile_path);
|
|
||||||
free(my_logfile_path);
|
free(my_logfile_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue