From dac5976c872589289e51440268f214a7e77d5627 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sun, 17 Feb 2013 10:20:10 +0100 Subject: [PATCH] Don't hardcode in an ext in fill_dated_*. --- file.h | 2 +- file_path.c | 11 +++-------- screenshot.c | 8 +++++++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/file.h b/file.h index d442d0d844..e0d6f2f75e 100644 --- a/file.h +++ b/file.h @@ -97,7 +97,7 @@ bool path_is_absolute(const char *path); // E.g.: in_path = "/foo/bar/baz/boo.c", replace = "" => out_path = "/foo/bar/baz/boo" void fill_pathname(char *out_path, const char *in_path, const char *replace, size_t size); -void fill_dated_filename(char *out_filename, size_t size); +void fill_dated_filename(char *out_filename, const char *ext, size_t size); // Appends a filename extension 'replace' to 'in_path', and outputs result in 'out_path'. // Assumes in_path has no extension. If an extension is still present in 'in_path', it will be ignored. diff --git a/file_path.c b/file_path.c index 9930d44a4f..8bc72c36c2 100644 --- a/file_path.c +++ b/file_path.c @@ -460,18 +460,13 @@ void fill_pathname_parent_dir(char *out_dir, const char *in_dir, size_t size) path_parent_dir(out_dir); } -void fill_dated_filename(char *out_filename, size_t size) +void fill_dated_filename(char *out_filename, const char *ext, size_t size) { time_t cur_time; time(&cur_time); -#ifdef HAVE_ZLIB_DEFLATE -#define IMG_EXT "png" -#else -#define IMG_EXT "bmp" -#endif - - strftime(out_filename, size, "RetroArch-%m%d-%H%M%S." IMG_EXT, localtime(&cur_time)); + strftime(out_filename, size, "RetroArch-%m%d-%H%M%S.", localtime(&cur_time)); + strlcat(out_filename, ext, size); } void path_basedir(char *path) diff --git a/screenshot.c b/screenshot.c index a20ab693c2..0a1f59d759 100644 --- a/screenshot.c +++ b/screenshot.c @@ -151,7 +151,13 @@ bool screenshot_dump(const char *folder, const void *frame, char filename[PATH_MAX]; char shotname[PATH_MAX]; - fill_dated_filename(shotname, sizeof(shotname)); +#ifdef HAVE_ZLIB_DEFLATE +#define IMG_EXT "png" +#else +#define IMG_EXT "bmp" +#endif + + fill_dated_filename(shotname, IMG_EXT, sizeof(shotname)); fill_pathname_join(filename, folder, shotname, sizeof(filename)); #ifdef HAVE_ZLIB_DEFLATE