Remove HAVE_COMPRESSION ifdefs in file_path.c

This commit is contained in:
twinaphex 2016-12-17 12:20:49 +01:00
parent 39b41a1f51
commit 4103b70833
13 changed files with 57 additions and 22 deletions

View File

@ -2233,7 +2233,7 @@ bool config_load_override(void)
if (system)
core_name = system->info.library_name;
game_name = path_basename(path_get(RARCH_PATH_BASENAME));
game_name = path_basename_special(path_get(RARCH_PATH_BASENAME));
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;
@ -2390,7 +2390,7 @@ bool config_load_remap(void)
if (system)
core_name = system->info.library_name;
game_name = path_basename(path_get(RARCH_PATH_BASENAME));
game_name = path_basename_special(path_get(RARCH_PATH_BASENAME));
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;
@ -2492,7 +2492,7 @@ bool config_load_shader_preset(void)
if (system)
core_name = system->info.library_name;
game_name = path_basename(path_get(RARCH_PATH_BASENAME));
game_name = path_basename_special(path_get(RARCH_PATH_BASENAME));
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;
@ -3092,7 +3092,7 @@ bool config_save_overrides(int override_type)
if (system)
core_name = system->info.library_name;
game_name = path_basename(path_get(RARCH_PATH_BASENAME));
game_name = path_basename_special(path_get(RARCH_PATH_BASENAME));
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;

View File

@ -534,3 +534,25 @@ void path_basedir_wrapper(char *path)
else
snprintf(path, 3, ".%s", path_default_slash());
}
/**
* path_basename:
* @path : path
*
* Get basename from @path.
*
* Returns: basename from path.
**/
const char *path_basename_special(const char *path)
{
#ifdef HAVE_COMPRESSION
/* We cut either at the first compression-related
* hash or the last slash; whichever comes last. */
const char *delim = path_get_archive_delim(path);
if (delim)
return delim + 1;
#endif
return path_basename(path);
}

View File

@ -21,6 +21,9 @@
#include <stddef.h>
#include <boolean.h>
#include <retro_common_api.h>
RETRO_BEGIN_DECLS
enum file_path_enum
{
@ -118,6 +121,16 @@ enum application_special_type
void fill_short_pathname_representation_wrapper(char* out_rep,
const char *in_path, size_t size);
/**
* path_basename_special:
* @path : path
*
* Get basename from @path.
*
* Returns: basename from path.
**/
const char *path_basename_special(const char *path);
/**
* path_basedir:
* @path : path
@ -133,4 +146,6 @@ bool fill_pathname_application_data(char *s, size_t len);
void fill_pathname_application_special(char *s, size_t len, enum application_special_type type);
RETRO_END_DECLS
#endif

View File

@ -28,6 +28,8 @@
#include "glslang_util.hpp"
#include "glslang.hpp"
#include "../../file_path_special.h"
#include "../../verbosity.h"
using namespace std;
@ -40,7 +42,7 @@ static bool read_shader_file(const char *path, vector<string> *output, bool root
char *ptr = NULL;
char *buf = nullptr;
ssize_t len = 0;
const char *basename = path_basename(path);
const char *basename = path_basename_special(path);
include_path[0] = tmp[0] = '\0';

View File

@ -510,16 +510,8 @@ void path_parent_dir(char *path)
**/
const char *path_basename(const char *path)
{
/* We cut either at the first compression-related hash or the last slash; whichever comes last */
const char *last = find_last_slash(path);
#ifdef HAVE_COMPRESSION
const char *delim = path_get_archive_delim(path);
if (delim)
return delim + 1;
#endif
if (last)
return last + 1;

View File

@ -1412,7 +1412,7 @@ static void menu_action_setting_disp_set_label_core_option_create(
strlcpy(s, "", len);
if (!string_is_empty(path_get(RARCH_PATH_BASENAME)))
strlcpy(s, path_basename(path_get(RARCH_PATH_BASENAME)), len);
strlcpy(s, path_basename_special(path_get(RARCH_PATH_BASENAME)), len);
strlcpy(s2, path, len2);
}

View File

@ -1693,7 +1693,7 @@ static int generic_action_ok_shader_preset_save(const char *path,
break;
case ACTION_OK_SHADER_PRESET_SAVE_GAME:
{
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
const char *game_name = path_basename_special(path_get(RARCH_PATH_BASENAME));
fill_pathname_join(file, directory, game_name, sizeof(file));
}
break;
@ -1803,7 +1803,8 @@ static int generic_action_ok_remap_file_save(const char *path,
case ACTION_OK_REMAP_FILE_SAVE_GAME:
if (!string_is_empty(core_name))
fill_pathname_join(file, core_name,
path_basename(path_get(RARCH_PATH_BASENAME)), sizeof(file));
path_basename_special(path_get(RARCH_PATH_BASENAME)),
sizeof(file));
break;
}

View File

@ -3413,7 +3413,7 @@ static int menu_displaylist_parse_cores(
path = str_list->elems[i].data;
if (!string_is_empty(info->path))
path = path_basename(path);
path = path_basename_special(path);
#ifndef HAVE_DYNAMIC
if (frontend_driver_has_fork())

View File

@ -908,7 +908,7 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir)
if (system)
core_name = system->info.library_name;
game_name = path_basename(path_get(RARCH_PATH_BASENAME));
game_name = path_basename_special(path_get(RARCH_PATH_BASENAME));
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;

View File

@ -393,7 +393,7 @@ static bool load_content_from_compressed_archive(
attributes.i = 0;
fill_pathname_join(new_path, new_basedir,
path_basename(path), sizeof(new_path));
path_basename_special(path), sizeof(new_path));
ret = file_archive_compressed_read(path, NULL, new_path, &new_path_len);

View File

@ -328,7 +328,7 @@ bool task_push_decompress(
t->user_data = user_data;
snprintf(tmp, sizeof(tmp), "%s '%s'",
msg_hash_to_str(MSG_EXTRACTING), path_basename(source_file));
msg_hash_to_str(MSG_EXTRACTING), path_basename_special(source_file));
t->title = strdup(tmp);

View File

@ -23,6 +23,8 @@
#include <net/net_compat.h>
#include <retro_stat.h>
#include "../file_path_special.h"
#include "../msg_hash.h"
#include "../verbosity.h"
#include "tasks_internal.h"
@ -291,7 +293,7 @@ void *task_push_http_transfer(const char *url, bool mute, const char *type,
t->progress = -1;
snprintf(tmp, sizeof(tmp), "%s '%s'",
msg_hash_to_str(MSG_DOWNLOADING), path_basename(url));
msg_hash_to_str(MSG_DOWNLOADING), path_basename_special(url));
t->title = strdup(tmp);

View File

@ -202,7 +202,8 @@ static bool screenshot_dump(
else
{
if (settings->auto_screenshot_filename)
fill_str_dated_filename(state->shotname, path_basename(name_base),
fill_str_dated_filename(state->shotname,
path_basename(name_base),
IMG_EXT, sizeof(state->shotname));
else
snprintf(state->shotname, sizeof(state->shotname),