mirror of
https://github.com/libretro/RetroArch
synced 2025-02-21 18:40:09 +00:00
Turn path_default_slash uppercase, and do some optimizations
This commit is contained in:
parent
601a73fa8b
commit
aa48eeb98e
@ -314,7 +314,7 @@ void fill_pathname_slash(char *path, size_t size)
|
|||||||
|
|
||||||
if (!last_slash)
|
if (!last_slash)
|
||||||
{
|
{
|
||||||
strlcat(path, path_default_slash(), size);
|
strlcat(path, PATH_DEFAULT_SLASH(), size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,7 +551,7 @@ void path_basedir(char *path)
|
|||||||
if (last)
|
if (last)
|
||||||
last[1] = '\0';
|
last[1] = '\0';
|
||||||
else
|
else
|
||||||
snprintf(path, 3, ".%s", path_default_slash());
|
snprintf(path, 3, "." PATH_DEFAULT_SLASH());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -809,7 +809,7 @@ size_t path_relative_to(char *out,
|
|||||||
|
|
||||||
/* Trim common beginning */
|
/* Trim common beginning */
|
||||||
for (i = 0, j = 0; path[i] && base[i] && path[i] == base[i]; i++)
|
for (i = 0, j = 0; path[i] && base[i] && path[i] == base[i]; i++)
|
||||||
if (path[i] == path_default_slash_c())
|
if (path[i] == PATH_DEFAULT_SLASH_C())
|
||||||
j = i + 1;
|
j = i + 1;
|
||||||
|
|
||||||
trimmed_path = path+j;
|
trimmed_path = path+j;
|
||||||
@ -818,8 +818,8 @@ size_t path_relative_to(char *out,
|
|||||||
/* Each segment of base turns into ".." */
|
/* Each segment of base turns into ".." */
|
||||||
out[0] = '\0';
|
out[0] = '\0';
|
||||||
for (i = 0; trimmed_base[i]; i++)
|
for (i = 0; trimmed_base[i]; i++)
|
||||||
if (trimmed_base[i] == path_default_slash_c())
|
if (trimmed_base[i] == PATH_DEFAULT_SLASH_C())
|
||||||
strlcat(out, ".." path_default_slash(), size);
|
strlcat(out, ".." PATH_DEFAULT_SLASH(), size);
|
||||||
|
|
||||||
return strlcat(out, trimmed_path, size);
|
return strlcat(out, trimmed_path, size);
|
||||||
}
|
}
|
||||||
@ -1006,7 +1006,7 @@ void fill_pathname_expand_special(char *out_path,
|
|||||||
|
|
||||||
if (!path_char_is_slash(out_path[-1]))
|
if (!path_char_is_slash(out_path[-1]))
|
||||||
{
|
{
|
||||||
src_size = strlcpy(out_path, path_default_slash(), size);
|
src_size = strlcpy(out_path, PATH_DEFAULT_SLASH(), size);
|
||||||
retro_assert(src_size < size);
|
retro_assert(src_size < size);
|
||||||
|
|
||||||
out_path += src_size;
|
out_path += src_size;
|
||||||
@ -1037,7 +1037,7 @@ void fill_pathname_expand_special(char *out_path,
|
|||||||
|
|
||||||
if (!path_char_is_slash(out_path[-1]))
|
if (!path_char_is_slash(out_path[-1]))
|
||||||
{
|
{
|
||||||
src_size = strlcpy(out_path, path_default_slash(), size);
|
src_size = strlcpy(out_path, PATH_DEFAULT_SLASH(), size);
|
||||||
retro_assert(src_size < size);
|
retro_assert(src_size < size);
|
||||||
|
|
||||||
out_path += src_size;
|
out_path += src_size;
|
||||||
@ -1101,7 +1101,7 @@ void fill_pathname_abbreviate_special(char *out_path,
|
|||||||
if (!path_char_is_slash(*in_path))
|
if (!path_char_is_slash(*in_path))
|
||||||
{
|
{
|
||||||
retro_assert(strlcpy(out_path,
|
retro_assert(strlcpy(out_path,
|
||||||
path_default_slash(), size) < size);
|
PATH_DEFAULT_SLASH(), size) < size);
|
||||||
out_path++;
|
out_path++;
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
@ -1140,7 +1140,7 @@ void path_basedir_wrapper(char *path)
|
|||||||
if (last)
|
if (last)
|
||||||
last[1] = '\0';
|
last[1] = '\0';
|
||||||
else
|
else
|
||||||
snprintf(path, 3, ".%s", path_default_slash());
|
snprintf(path, 3, "." PATH_DEFAULT_SLASH());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL)
|
#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL)
|
||||||
|
@ -473,11 +473,11 @@ void path_basedir_wrapper(char *path);
|
|||||||
* Returns: default slash separator.
|
* Returns: default slash separator.
|
||||||
*/
|
*/
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define path_default_slash() "\\"
|
#define PATH_DEFAULT_SLASH() "\\"
|
||||||
#define path_default_slash_c() '\\'
|
#define PATH_DEFAULT_SLASH_C() '\\'
|
||||||
#else
|
#else
|
||||||
#define path_default_slash() "/"
|
#define PATH_DEFAULT_SLASH() "/"
|
||||||
#define path_default_slash_c() '/'
|
#define PATH_DEFAULT_SLASH_C() '/'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -265,8 +265,8 @@ enum manual_content_scan_dat_file_path_status
|
|||||||
* Returns true if content directory is valid. */
|
* Returns true if content directory is valid. */
|
||||||
bool manual_content_scan_set_menu_content_dir(const char *content_dir)
|
bool manual_content_scan_set_menu_content_dir(const char *content_dir)
|
||||||
{
|
{
|
||||||
const char *dir_name = NULL;
|
|
||||||
size_t len;
|
size_t len;
|
||||||
|
const char *dir_name = NULL;
|
||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
if (string_is_empty(content_dir))
|
if (string_is_empty(content_dir))
|
||||||
@ -283,14 +283,12 @@ bool manual_content_scan_set_menu_content_dir(const char *content_dir)
|
|||||||
|
|
||||||
/* Remove trailing slash, if required */
|
/* Remove trailing slash, if required */
|
||||||
len = strlen(scan_settings.content_dir);
|
len = strlen(scan_settings.content_dir);
|
||||||
if (len > 0)
|
if (len <= 0)
|
||||||
{
|
|
||||||
if (scan_settings.content_dir[len - 1] == path_default_slash_c())
|
|
||||||
scan_settings.content_dir[len - 1] = '\0';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (scan_settings.content_dir[len - 1] == PATH_DEFAULT_SLASH_C())
|
||||||
|
scan_settings.content_dir[len - 1] = '\0';
|
||||||
|
|
||||||
/* Handle case where path was a single slash... */
|
/* Handle case where path was a single slash... */
|
||||||
if (string_is_empty(scan_settings.content_dir))
|
if (string_is_empty(scan_settings.content_dir))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -1935,7 +1935,8 @@ static void materialui_context_reset_textures(materialui_handle_t *mui)
|
|||||||
materialui_texture_path(i), icon_path, &mui->textures.list[i],
|
materialui_texture_path(i), icon_path, &mui->textures.list[i],
|
||||||
TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
||||||
{
|
{
|
||||||
RARCH_WARN("[GLUI] Asset missing: %s%s%s\n", icon_path, path_default_slash(), materialui_texture_path(i));
|
RARCH_WARN("[GLUI] Asset missing: %s%s%s\n", icon_path,
|
||||||
|
PATH_DEFAULT_SLASH(), materialui_texture_path(i));
|
||||||
has_all_assets = false;
|
has_all_assets = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -766,7 +766,8 @@ static void ozone_context_reset(void *data, bool is_threaded)
|
|||||||
sizeof(buf),
|
sizeof(buf),
|
||||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS);
|
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS);
|
||||||
if (!gfx_display_reset_textures_list(filename, buf, &ozone->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
if (!gfx_display_reset_textures_list(filename, buf, &ozone->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
||||||
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->png_path, path_default_slash(), filename);
|
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->png_path,
|
||||||
|
PATH_DEFAULT_SLASH(), filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -774,7 +775,8 @@ static void ozone_context_reset(void *data, bool is_threaded)
|
|||||||
if (!gfx_display_reset_textures_list(filename, ozone->png_path, &ozone->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
if (!gfx_display_reset_textures_list(filename, ozone->png_path, &ozone->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
||||||
{
|
{
|
||||||
ozone->has_all_assets = false;
|
ozone->has_all_assets = false;
|
||||||
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->png_path, path_default_slash(), filename);
|
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->png_path,
|
||||||
|
PATH_DEFAULT_SLASH(), filename);
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
}
|
}
|
||||||
@ -794,7 +796,8 @@ static void ozone_context_reset(void *data, bool is_threaded)
|
|||||||
if (!gfx_display_reset_textures_list(filename, ozone->tab_path, &ozone->tab_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
if (!gfx_display_reset_textures_list(filename, ozone->tab_path, &ozone->tab_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
||||||
{
|
{
|
||||||
ozone->has_all_assets = false;
|
ozone->has_all_assets = false;
|
||||||
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->tab_path, path_default_slash(), filename);
|
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->tab_path,
|
||||||
|
PATH_DEFAULT_SLASH(), filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,7 +811,8 @@ static void ozone_context_reset(void *data, bool is_threaded)
|
|||||||
if (!gfx_display_reset_textures_list(ozone_entries_icon_texture_path(i), ozone->icons_path, &ozone->icons_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
if (!gfx_display_reset_textures_list(ozone_entries_icon_texture_path(i), ozone->icons_path, &ozone->icons_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
||||||
{
|
{
|
||||||
ozone->has_all_assets = false;
|
ozone->has_all_assets = false;
|
||||||
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->icons_path, path_default_slash(), ozone_entries_icon_texture_path(i));
|
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->icons_path,
|
||||||
|
PATH_DEFAULT_SLASH(), ozone_entries_icon_texture_path(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,16 +902,17 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
|
|||||||
fill_pathname_join_delim(sysname, sysname,
|
fill_pathname_join_delim(sysname, sysname,
|
||||||
"content.png", '-',
|
"content.png", '-',
|
||||||
PATH_MAX_LENGTH * sizeof(char));
|
PATH_MAX_LENGTH * sizeof(char));
|
||||||
strlcat(content_texturepath, icons_path, PATH_MAX_LENGTH * sizeof(char));
|
strlcat(content_texturepath, icons_path,
|
||||||
|
PATH_MAX_LENGTH * sizeof(char));
|
||||||
strlcat(content_texturepath, path_default_slash(), PATH_MAX_LENGTH * sizeof(char));
|
strlcat(content_texturepath, PATH_DEFAULT_SLASH(),
|
||||||
|
PATH_MAX_LENGTH * sizeof(char));
|
||||||
strlcat(content_texturepath, sysname, PATH_MAX_LENGTH * sizeof(char));
|
strlcat(content_texturepath, sysname, PATH_MAX_LENGTH * sizeof(char));
|
||||||
|
|
||||||
/* If the content icon doesn't exist return default-content */
|
/* If the content icon doesn't exist return default-content */
|
||||||
if (!path_is_valid(content_texturepath))
|
if (!path_is_valid(content_texturepath))
|
||||||
{
|
{
|
||||||
strlcat(icons_path, path_default_slash(), PATH_MAX_LENGTH * sizeof(char));
|
strlcat(icons_path,
|
||||||
strlcat(icons_path, "default", PATH_MAX_LENGTH * sizeof(char));
|
PATH_DEFAULT_SLASH() "default", PATH_MAX_LENGTH * sizeof(char));
|
||||||
fill_pathname_join_delim(content_texturepath, icons_path,
|
fill_pathname_join_delim(content_texturepath, icons_path,
|
||||||
"content.png", '-',
|
"content.png", '-',
|
||||||
PATH_MAX_LENGTH * sizeof(char));
|
PATH_MAX_LENGTH * sizeof(char));
|
||||||
|
@ -811,12 +811,14 @@ bool ozone_reset_theme_textures(ozone_handle_t *ozone)
|
|||||||
for (i = 0; i < OZONE_THEME_TEXTURE_LAST; i++)
|
for (i = 0; i < OZONE_THEME_TEXTURE_LAST; i++)
|
||||||
{
|
{
|
||||||
char filename[PATH_MAX_LENGTH];
|
char filename[PATH_MAX_LENGTH];
|
||||||
strlcpy(filename, OZONE_THEME_TEXTURES_FILES[i], sizeof(filename));
|
strlcpy(filename, OZONE_THEME_TEXTURES_FILES[i],
|
||||||
|
sizeof(filename));
|
||||||
strlcat(filename, ".png", sizeof(filename));
|
strlcat(filename, ".png", sizeof(filename));
|
||||||
|
|
||||||
if (!gfx_display_reset_textures_list(filename, theme_path, &theme->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
if (!gfx_display_reset_textures_list(filename, theme_path, &theme->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
||||||
{
|
{
|
||||||
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", theme_path, path_default_slash(), filename);
|
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", theme_path,
|
||||||
|
PATH_DEFAULT_SLASH(), filename);
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19865,9 +19865,9 @@ static char *copy_core_to_temp_file(struct rarch_state *p_rarch)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
strcat_alloc(&retroarch_temp_path, temp_directory);
|
strcat_alloc(&retroarch_temp_path, temp_directory);
|
||||||
strcat_alloc(&retroarch_temp_path, path_default_slash());
|
strcat_alloc(&retroarch_temp_path, PATH_DEFAULT_SLASH());
|
||||||
strcat_alloc(&retroarch_temp_path, "retroarch_temp");
|
strcat_alloc(&retroarch_temp_path, "retroarch_temp");
|
||||||
strcat_alloc(&retroarch_temp_path, path_default_slash());
|
strcat_alloc(&retroarch_temp_path, PATH_DEFAULT_SLASH());
|
||||||
|
|
||||||
if (!path_mkdir(retroarch_temp_path))
|
if (!path_mkdir(retroarch_temp_path))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user