summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/Modules.cpp
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2013-02-28 16:14:30 +0000
committerKim van der Riet <kpvdr@apache.org>2013-02-28 16:14:30 +0000
commit9c73ef7a5ac10acd6a50d5d52bd721fc2faa5919 (patch)
tree2a890e1df09e5b896a9b4168a7b22648f559a1f2 /cpp/src/qpid/Modules.cpp
parent172d9b2a16cfb817bbe632d050acba7e31401cd2 (diff)
downloadqpid-python-asyncstore.tar.gz
Update from trunk r1375509 through r1450773asyncstore
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1451244 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/Modules.cpp')
-rw-r--r--cpp/src/qpid/Modules.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/cpp/src/qpid/Modules.cpp b/cpp/src/qpid/Modules.cpp
index 727e05d212..049ededaa7 100644
--- a/cpp/src/qpid/Modules.cpp
+++ b/cpp/src/qpid/Modules.cpp
@@ -24,11 +24,7 @@
#include "qpid/Exception.h"
#include "qpid/log/Statement.h"
#include "qpid/sys/Shlib.h"
-
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
-namespace fs=boost::filesystem;
+#include "qpid/sys/FileSysDir.h"
namespace {
@@ -43,7 +39,7 @@ inline std::string& suffix() {
}
bool isShlibName(const std::string& name) {
- return name.find (suffix()) == name.length() - suffix().length();
+ return name.substr(name.size()-suffix().size()) == suffix();
}
}
@@ -59,39 +55,40 @@ ModuleOptions::ModuleOptions(const std::string& defaultModuleDir)
("no-module-dir", optValue(noLoad), "Don't load modules from module directory");
}
-void tryShlib(const char* libname_, bool noThrow) {
- std::string libname(libname_);
- if (!isShlibName(libname)) libname += suffix();
+void tryShlib(const std::string& libname) {
+ sys::Shlib shlib( isShlibName(libname) ? libname : (libname + suffix()));
+}
+
+namespace {
+
+void tryOnlyShlib(const std::string& libname) throw() {
try {
- sys::Shlib shlib(libname);
+ if (isShlibName(libname)) sys::Shlib shlib( libname );
}
catch (const std::exception& /*e*/) {
- if (!noThrow)
- throw;
}
}
+}
+
void loadModuleDir (std::string dirname, bool isDefault)
{
- fs::path dirPath (dirname, fs::native);
- if (!fs::exists (dirPath))
+ sys::FileSysDir dirPath (dirname);
+
+ bool exists;
+ try
{
- if (isDefault)
- return;
- throw Exception ("Directory not found: " + dirname);
+ exists = dirPath.exists();
+ } catch (Exception& e) {
+ throw Exception ("Invalid value for module-dir: " + e.getMessage());
}
- if (!fs::is_directory(dirPath))
- {
- throw Exception ("Invalid value for module-dir: " + dirname + " is not a directory");
+ if (!exists) {
+ if (isDefault) return;
+ throw Exception ("Directory not found: " + dirname);
}
- fs::directory_iterator endItr;
- for (fs::directory_iterator itr (dirPath); itr != endItr; ++itr)
- {
- if (!fs::is_directory(*itr) && isShlibName(itr->string()))
- tryShlib (itr->string().data(), true);
- }
+ dirPath.forEachFile(&tryOnlyShlib);
}
} // namespace qpid