From e7e20fab1b2b90ea80e118959386017ed1d6f703 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sat, 19 Nov 2022 22:39:14 -0500 Subject: create function open_pathfmt() to allow printf formatting on open() save some space by allowing printf formatting directly rather than having a buffer and using sprintf Change-Id: I049c8f898fb4a68a26ad0f0646250c242647ba12 --- apps/logfdisp.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'apps/logfdisp.c') diff --git a/apps/logfdisp.c b/apps/logfdisp.c index b139f30ac7..aebc9ffb33 100644 --- a/apps/logfdisp.c +++ b/apps/logfdisp.c @@ -35,7 +35,9 @@ #include "logfdisp.h" #include "action.h" #include "splash.h" - +#if CONFIG_RTC +#include "misc.h" +#endif /*CONFIG_RTC*/ int compute_nb_lines(int w, struct font* font) { int i, nb_lines; @@ -212,10 +214,6 @@ bool logfdisplay(void) bool logfdump(void) { int fd; -#if CONFIG_RTC - struct tm *nowtm; - char fname[MAX_PATH]; -#endif splashf(HZ, "Log File Dumped"); @@ -227,11 +225,11 @@ bool logfdump(void) logfenabled = false; #if CONFIG_RTC - nowtm = get_time(); - snprintf(fname, MAX_PATH, "%s/logf_%04d%02d%02d%02d%02d%02d.txt", ROCKBOX_DIR, + struct tm *nowtm = get_time(); + fd = open_pathfmt(O_CREAT|O_WRONLY|O_TRUNC, + "%s/logf_%04d%02d%02d%02d%02d%02d.txt", ROCKBOX_DIR, nowtm->tm_year + 1900, nowtm->tm_mon + 1, nowtm->tm_mday, nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec); - fd = open(fname, O_CREAT|O_WRONLY|O_TRUNC); #else fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC, 0666); #endif -- cgit v1.2.3