diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 2fd572c394..2f2a7e772d 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -415,14 +415,38 @@ void fill_pathname_parent_dir(char *out_dir, void fill_dated_filename(char *out_filename, const char *ext, size_t size) { - time_t cur_time; - time(&cur_time); + time_t cur_time = time(NULL); strftime(out_filename, size, "RetroArch-%m%d-%H%M%S.", localtime(&cur_time)); strlcat(out_filename, ext, size); } +/** + * fill_str_dated_filename: + * @out_filename : output filename + * @in_str : input string + * @ext : extension of output filename + * @size : buffer size of output filename + * + * Creates a 'dated' filename prefixed by the string @in_str, and + * concatenates extension (@ext) to it. + * + * E.g.: + * out_filename = "RetroArch-{year}{month}{day}-{Hour}{Minute}{Second}.{@ext}" + **/ +void fill_str_dated_filename(char *out_filename, + const char *in_str, const char *ext, size_t size) +{ + char format[256] = {0}; + time_t cur_time = time(NULL); + + strftime(format, sizeof(format), "-%y%m%d-%H%M%S.", localtime(&cur_time)); + strlcpy(out_filename, in_str, size); + strlcat(out_filename, format, size); + strlcat(out_filename, ext, size); +} + /** * path_basedir: * @path : path diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index b861373b71..08dba54aad 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -194,6 +194,22 @@ void fill_pathname(char *out_path, const char *in_path, void fill_dated_filename(char *out_filename, const char *ext, size_t size); +/** + * fill_str_dated_filename: + * @out_filename : output filename + * @in_str : input string + * @ext : extension of output filename + * @size : buffer size of output filename + * + * Creates a 'dated' filename prefixed by the string @in_str, and + * concatenates extension (@ext) to it. + * + * E.g.: + * out_filename = "RetroArch-{year}{month}{day}-{Hour}{Minute}{Second}.{@ext}" + **/ +void fill_str_dated_filename(char *out_filename, + const char *in_str, const char *ext, size_t size); + /** * fill_pathname_noext: * @out_path : output path diff --git a/tasks/task_screenshot.c b/tasks/task_screenshot.c index 0dbfe70caf..525fbeaeb5 100644 --- a/tasks/task_screenshot.c +++ b/tasks/task_screenshot.c @@ -78,14 +78,14 @@ static bool screenshot_dump( if (settings->auto_screenshot_filename) { - fill_dated_filename(shotname, IMG_EXT, sizeof(shotname)); - fill_pathname_join(filename, folder, shotname, sizeof(filename)); + fill_str_dated_filename(shotname, path_basename(global_name_base), + IMG_EXT, sizeof(shotname)); } else { snprintf(shotname, sizeof(shotname),"%s.png", path_basename(global_name_base)); - fill_pathname_join(filename, folder, shotname, sizeof(filename)); } + fill_pathname_join(filename, folder, shotname, sizeof(filename)); #ifdef _XBOX1 d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(true);