mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-09 19:02:37 +00:00
We check dynamically in file.c if the filename contains a zipfile
This commit is contained in:
parent
502475f6c7
commit
9c4c2a107c
73
file.c
73
file.c
@ -138,48 +138,45 @@ static ssize_t read_content_file(const char *path, void **buf)
|
||||
* inside an archive, or not.
|
||||
*
|
||||
* We determine, whether a file is inside a compressed archive,
|
||||
* by checking, if the archive string is a substring of the
|
||||
* complete path
|
||||
* by checking for the # inside the URL.
|
||||
*
|
||||
* For example: fullpath: /home/user/game.7z/mygame.rom
|
||||
* carchive_path: /home/user/game.7z
|
||||
* */
|
||||
|
||||
#ifdef HAVE_COMPRESSION
|
||||
const char* archive_found = (const char*)strstr(path,
|
||||
g_extern.carchive_path);
|
||||
|
||||
if (g_extern.is_carchive)
|
||||
if (path_contains_compressed_file(path))
|
||||
{
|
||||
if(archive_found)
|
||||
{
|
||||
if (strlen(path) < strlen(g_extern.carchive_path)+2)
|
||||
{
|
||||
/*
|
||||
* This error condition happens for example, when
|
||||
* carchive_path == path, or
|
||||
* carchive_path + '/' == path.
|
||||
*/
|
||||
RARCH_ERR("Could not extract image path %s from carchive path %s.\n",
|
||||
path, g_extern.carchive_path);
|
||||
return -1;
|
||||
}
|
||||
ret = read_compressed_file(g_extern.carchive_path,
|
||||
archive_found + strlen(g_extern.carchive_path) + 1,
|
||||
(void**)&ret_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If we didn't actually find the archivename in the filename
|
||||
* the given path is not inside the archive. Then we proceed to
|
||||
* just load the file.
|
||||
*/
|
||||
ret = read_file(path, (void**)&ret_buf);
|
||||
}
|
||||
//We split carchive path and relative path:
|
||||
char archive_path[PATH_MAX];
|
||||
strlcpy(archive_path,path,sizeof(archive_path));
|
||||
char* archive_found = strchr(archive_path,'#');
|
||||
|
||||
//We assure that there is something after the '#' symbol
|
||||
if (strlen(archive_found) <= 1)
|
||||
{
|
||||
/*
|
||||
* This error condition happens for example, when
|
||||
* path = /path/to/file.7z, or
|
||||
* path = /path/to/file.7z#
|
||||
*/
|
||||
RARCH_ERR("Could not extract image path and carchive path from "
|
||||
"path: %s.\n", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rarch_assert(archive_found != NULL);
|
||||
*archive_found = '\0';
|
||||
|
||||
archive_found+=1;
|
||||
printf("relative_path: %s, archive_path: %s\n",archive_found,archive_path);
|
||||
ret = read_compressed_file(archive_path,
|
||||
archive_found,
|
||||
(void**)&ret_buf);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
ret = read_file(path, (void**)&ret_buf);
|
||||
ret = read_file(path, (void**) &ret_buf);
|
||||
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
@ -407,7 +404,6 @@ static bool load_content(const struct retro_subsystem_info *special,
|
||||
}
|
||||
|
||||
info[i].path = *path ? path : NULL;
|
||||
|
||||
if (!need_fullpath && *path)
|
||||
{
|
||||
/* Load the content into memory. */
|
||||
@ -429,7 +425,16 @@ static bool load_content(const struct retro_subsystem_info *special,
|
||||
info[i].size = size;
|
||||
}
|
||||
else
|
||||
RARCH_LOG("Content loading skipped. Implementation will load it on its own.\n");
|
||||
{
|
||||
RARCH_LOG("Content loading skipped. Implementation will"
|
||||
" load it on its own.\n");
|
||||
if (need_fullpath && path_contains_compressed_file(path))
|
||||
{
|
||||
RARCH_ERR("Compressed files are only supported for drivers,"
|
||||
" where need_fullpath is set to false.\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (special)
|
||||
|
Loading…
x
Reference in New Issue
Block a user