mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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
This commit is contained in:
parent
8fe42c43c6
commit
e7e20fab1b
8 changed files with 42 additions and 53 deletions
10
apps/misc.c
10
apps/misc.c
|
@ -1418,6 +1418,16 @@ int string_option(const char *option, const char *const oplist[], bool ignore_ca
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* open but with a builtin printf for assembling the path */
|
||||
int open_pathfmt(int oflag, const char *pathfmt, ...)
|
||||
{
|
||||
static char buf[MAX_PATH];
|
||||
va_list ap;
|
||||
vsnprintf(buf, sizeof(buf), pathfmt, ap);
|
||||
va_end(ap);
|
||||
return open(buf, oflag, 0666);
|
||||
}
|
||||
|
||||
/** Open a UTF-8 file and set file descriptor to first byte after BOM.
|
||||
* If no BOM is present this behaves like open().
|
||||
* If the file is opened for writing and O_TRUNC is set, write a BOM to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue