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=rpm
  • y: 1=amd64 | 2=x86
  • z: 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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -