diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-11-19 22:39:14 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2022-11-19 23:13:42 -0500 |
commit | e7e20fab1b2b90ea80e118959386017ed1d6f703 (patch) | |
tree | df435e8bc4a4d9069a365061454443ae9e33ded3 /apps/logfdisp.c | |
parent | 8fe42c43c6c62a8f593ee337902f8919ed2152ad (diff) | |
download | rockbox-e7e20fab1b2b90ea80e118959386017ed1d6f703.tar.gz rockbox-e7e20fab1b2b90ea80e118959386017ed1d6f703.zip |
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
Diffstat (limited to 'apps/logfdisp.c')
-rw-r--r-- | apps/logfdisp.c | 14 |
1 files changed, 6 insertions, 8 deletions
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 @@ | |||
35 | #include "logfdisp.h" | 35 | #include "logfdisp.h" |
36 | #include "action.h" | 36 | #include "action.h" |
37 | #include "splash.h" | 37 | #include "splash.h" |
38 | 38 | #if CONFIG_RTC | |
39 | #include "misc.h" | ||
40 | #endif /*CONFIG_RTC*/ | ||
39 | int compute_nb_lines(int w, struct font* font) | 41 | int compute_nb_lines(int w, struct font* font) |
40 | { | 42 | { |
41 | int i, nb_lines; | 43 | int i, nb_lines; |
@@ -212,10 +214,6 @@ bool logfdisplay(void) | |||
212 | bool logfdump(void) | 214 | bool logfdump(void) |
213 | { | 215 | { |
214 | int fd; | 216 | int fd; |
215 | #if CONFIG_RTC | ||
216 | struct tm *nowtm; | ||
217 | char fname[MAX_PATH]; | ||
218 | #endif | ||
219 | 217 | ||
220 | splashf(HZ, "Log File Dumped"); | 218 | splashf(HZ, "Log File Dumped"); |
221 | 219 | ||
@@ -227,11 +225,11 @@ bool logfdump(void) | |||
227 | logfenabled = false; | 225 | logfenabled = false; |
228 | 226 | ||
229 | #if CONFIG_RTC | 227 | #if CONFIG_RTC |
230 | nowtm = get_time(); | 228 | struct tm *nowtm = get_time(); |
231 | snprintf(fname, MAX_PATH, "%s/logf_%04d%02d%02d%02d%02d%02d.txt", ROCKBOX_DIR, | 229 | fd = open_pathfmt(O_CREAT|O_WRONLY|O_TRUNC, |
230 | "%s/logf_%04d%02d%02d%02d%02d%02d.txt", ROCKBOX_DIR, | ||
232 | nowtm->tm_year + 1900, nowtm->tm_mon + 1, nowtm->tm_mday, | 231 | nowtm->tm_year + 1900, nowtm->tm_mon + 1, nowtm->tm_mday, |
233 | nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec); | 232 | nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec); |
234 | fd = open(fname, O_CREAT|O_WRONLY|O_TRUNC); | ||
235 | #else | 233 | #else |
236 | fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC, 0666); | 234 | fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC, 0666); |
237 | #endif | 235 | #endif |