C : Auto-complete file names matching a pattern in access() or execl() on unix / linux -
i having program masterprog
exec()s binary matching specific pattern amongst multiple such files slaveprog.1.1.0
, slaveprog.1.2.1
, slaveprog.2.1.10
, ... within same directory.
to more clear, masterprog
checks environment in system (in case ubuntu 16.04 lts amd64) , looks few more factors , decides slaveprog.x.y.z
execute. slaveprog
naming convention follows:
x
: 1=debian | 2=rpmy
: 1=amd64 | 2=x86z
: latest slaveprog version
my master program able generate slaveprog.1.1.
environment , calls:
access("./slaveprog.1.1.*",f_ok); // verify if file exists execl("/slaveprog.1.1.*","/slaveprog.1.1.*",null);
but unfortunately access()
returns -1
if slaveprog.1.1.3
exists in current working directory.
can suggest me if there simpler way open directory, list files , select appropriate file achieve this?
Comments
Post a Comment