Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use stat to get the file information instead of dirent d_type

Open-webOS-DCO-1.0-Signed-off-by: Suresh Arumugam <suresh.arumugam@palm.com>

Change-Id: I11562200d4146c1d9ab3bd14a4deabf2b536f52e
  • Loading branch information...
commit 3e9f82164f2e83e75582c9c2bf31d65051c3dc3e 1 parent a2a2206
@sarumugam sarumugam authored
Showing with 18 additions and 12 deletions.
  1. +18 −12 src/Configurator.cpp
View
30 src/Configurator.cpp
@@ -404,6 +404,7 @@ void Configurator::GetConfigFiles(const string& parent, const string& directory)
DIR* dp = NULL;
struct dirent* dirp = NULL;
+ struct stat stat_buf;
MojLogInfo(m_log, "Finding config files in '%s' under '%s'", directory.c_str(), parent.c_str());
if((dp = opendir(directory.c_str())) == NULL) {
@@ -417,21 +418,26 @@ void Configurator::GetConfigFiles(const string& parent, const string& directory)
string filePath = directory;
filePath.append("/");
filePath.append(filename);
-
- if (dirp->d_type == DT_DIR) {
- GetConfigFiles(filename, filePath);
- } else {
- if (! parent.empty())
- m_parentDirMap[filePath] = parent;
-
- // Check if the config file has already been processed
- if (!(m_currentType == Configure && IsAlreadyConfigured(filePath))) {
- MojLogDebug(m_log, "Found configuration '%s'", filePath.c_str());
- m_configs.push_back(filePath);
+ if(0 == stat(filePath.c_str(), &stat_buf)) {
+ if (S_ISDIR(stat_buf.st_mode)) {
+ GetConfigFiles(filename, filePath);
} else {
- MojLogDebug(m_log, "Skipping configuration '%s' because it has already run (cache stamp in %s exists)", filePath.c_str(), kConfCacheDir);
+ if (! parent.empty())
+ m_parentDirMap[filePath] = parent;
+
+ // Check if the config file has already been processed
+ if (!(m_currentType == Configure && IsAlreadyConfigured(filePath))) {
+ MojLogDebug(m_log, "Found configuration '%s'", filePath.c_str());
+ m_configs.push_back(filePath);
+ } else {
+ MojLogDebug(m_log, "Skipping configuration '%s' because it has already run (cache stamp in %s exists)", filePath.c_str(), kConfCacheDir);
+ }
}
}
+ else {
+ MojLogError(m_log, "Failed to get file information on: %s", filename.c_str());
+ break;
+ }
}
}
closedir(dp);
Please sign in to comment.
Something went wrong with that request. Please try again.