Tar recognition

Tar recognition
This commit is contained in:
Andy Vandijck 2025-07-13 10:11:02 +02:00
parent e42e6323e8
commit 379be68f69
4 changed files with 20 additions and 1 deletions

View File

@ -26,6 +26,7 @@ uint8_t *utilLoad(const char *, bool (*)(const char *), uint8_t *, int &);
IMAGE_TYPE utilFindType(const char *);
bool utilIsGBAImage(const char *);
bool utilIsGBImage(const char *);
bool utilIsTARAchive(const char *);
#if defined(__LIBRETRO__)
@ -58,4 +59,4 @@ void utilWriteInt(gzFile, int);
#endif // defined(__LIBRETRO__)
#endif // VBAM_CORE_BASE_FILE_UTIL_H_
#endif // VBAM_CORE_BASE_FILE_UTIL_H_

View File

@ -39,6 +39,15 @@ FILE* utilOpenFile(const char* filename, const char* mode) {
#endif // _WIN32
}
bool utilIsTARAchive(const char* file) {
const char* p = strrchr(file, '.');
if ((strcasecmp(p, ".tar") == 0))
return true;
return false;
}
bool utilIsGBAImage(const char* file) {
coreOptions.cpuIsMultiBoot = false;
if (strlen(file) > 4) {

View File

@ -141,6 +141,7 @@ uint8_t* utilLoad(const char* file, bool (*accept)(const char*), uint8_t* data,
int read = fileSize <= size ? fileSize : size; // do not read beyond file
err = fex_read(fe, image, read);
fex_close(fe);
if (err) {
systemMessage(MSG_ERROR_READING_IMAGE, N_("Error reading image from %s: %s"), buffer, err);
if (data == nullptr)

View File

@ -65,7 +65,11 @@ blargg_err_t Tar_Extractor::open_v()
{
arc().read(&header, BLOCKSIZE);
set_name( header.name );
#if __STDC_WANT_SECURE_LIB__
sscanf_s(header.size, "%o", &tarsize);
#else
sscanf(header.size, "%o", &tarsize);
#endif
return blargg_ok;
}
@ -78,7 +82,11 @@ blargg_err_t Tar_Extractor::next_v()
{
arc().read(&header, BLOCKSIZE);
set_name( header.name );
#if __STDC_WANT_SECURE_LIB__
sscanf_s(header.size, "%o", &tarsize);
#else
sscanf(header.size, "%o", &tarsize);
#endif
return blargg_ok;
}