mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 02:27:26 -07:00
add simple detection of file based on extension ftc
This commit is contained in:
parent
bd57430058
commit
6416aaa52b
2 changed files with 45 additions and 0 deletions
|
@ -77,6 +77,44 @@ struct wave_info_t {
|
||||||
} PACKED audio_data;
|
} PACKED audio_data;
|
||||||
} PACKED;
|
} PACKED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief detects if file is of a supported filetype based on extension
|
||||||
|
* @param filename
|
||||||
|
* @return o
|
||||||
|
*/
|
||||||
|
DumpFileType_t getfiletype(const char *filename) {
|
||||||
|
// assume unknown file is BINARY
|
||||||
|
DumpFileType_t o = BIN;
|
||||||
|
if (filename == NULL) {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t len = strlen(filename);
|
||||||
|
if (len > 4) {
|
||||||
|
// check if valid file extension and attempt to load data
|
||||||
|
char s[FILE_PATH_SIZE];
|
||||||
|
memset(s, 0, sizeof(s));
|
||||||
|
memcpy(s, filename, len);
|
||||||
|
str_lower(s);
|
||||||
|
|
||||||
|
if (str_endswith(s, "bin")) {
|
||||||
|
o = BIN;
|
||||||
|
} else if (str_endswith(s, "eml")) {
|
||||||
|
o = EML;
|
||||||
|
} else if (str_endswith(s, "json")) {
|
||||||
|
o = JSON;
|
||||||
|
} else if (str_endswith(s, "dic")) {
|
||||||
|
o = DICTIONARY;
|
||||||
|
} else {
|
||||||
|
// mfd, trc, trace is binary
|
||||||
|
o = BIN;
|
||||||
|
// log is text
|
||||||
|
// .pm3 is text values of signal data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief checks if a file exists
|
* @brief checks if a file exists
|
||||||
* @param filename
|
* @param filename
|
||||||
|
|
|
@ -272,4 +272,11 @@ mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose);
|
||||||
int searchAndList(const char *pm3dir, const char *ext);
|
int searchAndList(const char *pm3dir, const char *ext);
|
||||||
int searchFile(char **foundpath, const char *pm3dir, const char *searchname, const char *suffix, bool silent);
|
int searchFile(char **foundpath, const char *pm3dir, const char *searchname, const char *suffix, bool silent);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief detects if file is of a supported filetype based on extension
|
||||||
|
* @param filename
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
DumpFileType_t getfiletype(const char *filename);
|
||||||
#endif // FILEUTILS_H
|
#endif // FILEUTILS_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue