added fill_str_dated_filename() function

This function creates a 'dated' filename prefixed by the string `in_str`, and concatenates extension (`ext`) to it.
This commit is contained in:
meleu 2016-08-19 08:45:58 -03:00 committed by GitHub
parent 4b9ced1cd8
commit 4e44ab99a1

View File

@ -423,6 +423,32 @@ void fill_dated_filename(char *out_filename,
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[PATH_MAX_LENGTH] = {0};
time_t cur_time;
time(&cur_time);
snprintf(format, sizeof(format),
"%s-%%y%%m%%d-%%H%%M%%S.", in_str);
strftime(out_filename, size, format, localtime(&cur_time));
strlcat(out_filename, ext, size);
}
/**
* path_basedir:
* @path : path