Skip DIR and non files when gathering list of executables
This commit is contained in:
parent
eee6df25a0
commit
ca9724f1f8
1 changed files with 9 additions and 1 deletions
|
@ -34,6 +34,7 @@
|
||||||
#include <stdarg.h> // for va_list
|
#include <stdarg.h> // for va_list
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
bool Util::Config::is_active = false;
|
bool Util::Config::is_active = false;
|
||||||
|
@ -784,7 +785,14 @@ void Util::getMyExec(std::deque<std::string> &execs){
|
||||||
do{
|
do{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if ((dp = readdir(d))){
|
if ((dp = readdir(d))){
|
||||||
if (strncmp(dp->d_name, "Mist", 4) == 0){execs.push_back(dp->d_name);}
|
if (dp->d_type != DT_DIR && strncmp(dp->d_name, "Mist", 4) == 0){
|
||||||
|
if (dp->d_type != DT_REG) {
|
||||||
|
struct stat st = {};
|
||||||
|
stat(dp->d_name, &st);
|
||||||
|
if (!S_ISREG(st.st_mode))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
execs.push_back(dp->d_name);}
|
||||||
}
|
}
|
||||||
}while (dp != NULL);
|
}while (dp != NULL);
|
||||||
closedir(d);
|
closedir(d);
|
||||||
|
|
Loading…
Add table
Reference in a new issue