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/misc.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/misc.c')
-rw-r--r-- | apps/misc.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/apps/misc.c b/apps/misc.c index 0bac986a6f..66d1c272ae 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -1418,6 +1418,16 @@ int string_option(const char *option, const char *const oplist[], bool ignore_ca | |||
1418 | return -1; | 1418 | return -1; |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | /* open but with a builtin printf for assembling the path */ | ||
1422 | int open_pathfmt(int oflag, const char *pathfmt, ...) | ||
1423 | { | ||
1424 | static char buf[MAX_PATH]; | ||
1425 | va_list ap; | ||
1426 | vsnprintf(buf, sizeof(buf), pathfmt, ap); | ||
1427 | va_end(ap); | ||
1428 | return open(buf, oflag, 0666); | ||
1429 | } | ||
1430 | |||
1421 | /** Open a UTF-8 file and set file descriptor to first byte after BOM. | 1431 | /** Open a UTF-8 file and set file descriptor to first byte after BOM. |
1422 | * If no BOM is present this behaves like open(). | 1432 | * If no BOM is present this behaves like open(). |
1423 | * If the file is opened for writing and O_TRUNC is set, write a BOM to | 1433 | * If the file is opened for writing and O_TRUNC is set, write a BOM to |