mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 10:10:57 +00:00
(task_screenshot.c) Cleanups - don't use snprintf unless necessary
This commit is contained in:
parent
8928052863
commit
698387e762
@ -71,6 +71,10 @@ static INLINE bool string_is_equal(const char *a, const char *b)
|
||||
(s)[(size)] = '*'; \
|
||||
(s)[(size)+1] = '\0'
|
||||
|
||||
#define string_add_dot_fast(s, size) \
|
||||
(s)[(size)] = '.'; \
|
||||
(s)[(size)+1] = '\0'
|
||||
|
||||
#define string_add_space_fast(s, size) \
|
||||
(s)[(size)] = ' '; \
|
||||
(s)[(size)+1] = '\0'
|
||||
|
@ -260,8 +260,15 @@ static bool screenshot_dump(
|
||||
if (!fullpath)
|
||||
{
|
||||
if (savestate)
|
||||
snprintf(state->filename,
|
||||
sizeof(state->filename), "%s.png", name_base);
|
||||
{
|
||||
size_t copied = strlcpy(state->filename,
|
||||
name_base, sizeof(state->filename));
|
||||
string_add_dot_fast(state->filename, copied);
|
||||
state->filename[copied+1] = 'p';
|
||||
state->filename[copied+2] = 'n';
|
||||
state->filename[copied+3] = 'g';
|
||||
state->filename[copied+4] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (settings->bools.auto_screenshot_filename)
|
||||
@ -285,8 +292,15 @@ static bool screenshot_dump(
|
||||
IMG_EXT, sizeof(state->shotname));
|
||||
}
|
||||
else
|
||||
snprintf(state->shotname, sizeof(state->shotname),
|
||||
"%s.png", path_basename(name_base));
|
||||
{
|
||||
size_t copied = strlcpy(state->shotname, path_basename(name_base),
|
||||
sizeof(state->shotname));
|
||||
string_add_dot_fast(state->shotname, copied);
|
||||
state->shotname[copied+1] = 'p';
|
||||
state->shotname[copied+2] = 'n';
|
||||
state->shotname[copied+3] = 'g';
|
||||
state->shotname[copied+4] = '\0';
|
||||
}
|
||||
|
||||
if ( string_is_empty(screenshot_dir) ||
|
||||
settings->bools.screenshots_in_content_dir)
|
||||
|
Loading…
Reference in New Issue
Block a user