View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0000333||file||General||public||2022-03-24 08:26||2022-03-24 08:26|
|Summary||0000333: Introduce a magic_file_at() function|
|Description||I suggest introducing a new libmagic API function: magic_file_at which will have the signature:|
const char *magic_file_at(magic_t cookie, int dirfd, const char *path)
It behaves exactly like magic_file() except that if path is relative then it is interpreted as a relative path to the directory referred to by dirfd except if dirfd is negative in which case path is interpreted as a relative path to the current working directory.
This is analogous to the openat() family of syscalls (except that AT_FDCWD is changed with any negative value).
The rationale behind this addition is laid out in the Linux mapage for open(2) but also, in my personal experience, it simplifies the use of readdir() greatly as no string copying needs to take place to call magic_file().
|Tags||No tags attached.|