summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/src/CAmRoutingSender.cpp
diff options
context:
space:
mode:
authorChristian Linke <christian.linke@bmw.de>2013-09-02 13:37:37 +0200
committerChristian Linke <christian.linke@bmw.de>2013-09-02 13:37:37 +0200
commitee80a9d43cfedd41e91a825a0733eaf6cc59b26a (patch)
tree97a91410126ab404a2921a4c59908df10bd9f59c /AudioManagerDaemon/src/CAmRoutingSender.cpp
parentda1d038f907a1ef3df2c1fa3c645918e4e1e641e (diff)
downloadaudiomanager-ee80a9d43cfedd41e91a825a0733eaf6cc59b26a.tar.gz
Handle cases where readdir() does not return the file type
readdir() does not guarantee that the d_type member is set on all file systems. This resulted in plugins not being loaded on some platforms as regular files were not detected. Signed-off-by: Christian Linke <christian.linke@bmw.de>
Diffstat (limited to 'AudioManagerDaemon/src/CAmRoutingSender.cpp')
-rw-r--r--AudioManagerDaemon/src/CAmRoutingSender.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/AudioManagerDaemon/src/CAmRoutingSender.cpp b/AudioManagerDaemon/src/CAmRoutingSender.cpp
index 590f6df..5f7f03a 100644
--- a/AudioManagerDaemon/src/CAmRoutingSender.cpp
+++ b/AudioManagerDaemon/src/CAmRoutingSender.cpp
@@ -22,6 +22,9 @@
#include "CAmRoutingSender.h"
#include <utility>
#include <dirent.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <dlfcn.h>
#include <cassert>
#include <iostream>
@@ -71,10 +74,23 @@ CAmRoutingSender::CAmRoutingSender(const std::vector<std::string>& listOfPluginD
{
unsigned char entryType = itemInDirectory->d_type;
std::string entryName = itemInDirectory->d_name;
+ std::string fullName = *dirIter + "/" + entryName;
bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
bool sharedLibExtension = ("so" == entryName.substr(entryName.find_last_of(".") + 1));
+ // Handle cases where readdir() could not determine the file type
+ if (entryType == DT_UNKNOWN) {
+ struct stat buf;
+
+ if (stat(fullName.c_str(), &buf)) {
+ logInfo(__PRETTY_FUNCTION__,"Failed to stat file: ", entryName, errno);
+ continue;
+ }
+
+ regularFile = S_ISREG(buf.st_mode);
+ }
+
if (regularFile && sharedLibExtension)
{
logInfo("RoutingSender::RoutingSender adding file: ", entryName);