mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 02:34:48 +08:00
filechecks.. could fail stat call and directory could be symlinked
This commit is contained in:
parent
c4249ecbb8
commit
6d1e109c82
1 changed files with 12 additions and 8 deletions
|
@ -77,13 +77,15 @@ int fileExists(const char *filename) {
|
||||||
bool is_regular_file(const char *filename) {
|
bool is_regular_file(const char *filename) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct _stat st;
|
struct _stat st;
|
||||||
_stat(filename, &st);
|
if (_stat(filename, &st) == -1)
|
||||||
return S_ISREG(st.st_mode) != 0;
|
return false;
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
stat(filename, &st);
|
// stat(filename, &st);
|
||||||
return S_ISREG(st.st_mode) != 0;
|
if (lstat(filename, &st) == -1)
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
return S_ISREG(st.st_mode) != 0;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief checks if path is directory.
|
* @brief checks if path is directory.
|
||||||
|
@ -93,13 +95,15 @@ bool is_regular_file(const char *filename) {
|
||||||
bool is_directory(const char *filename) {
|
bool is_directory(const char *filename) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct _stat st;
|
struct _stat st;
|
||||||
_stat(filename, &st);
|
if (_stat(filename, &st) == -1)
|
||||||
return S_ISDIR(st.st_mode) != 0;
|
return false;
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
stat(filename, &st);
|
// stat(filename, &st);
|
||||||
return S_ISDIR(st.st_mode) != 0;
|
if (lstat(filename, &st) == -1)
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
return S_ISDIR(st.st_mode) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue