aboutsummaryrefslogtreecommitdiff
path: root/lib/System
diff options
context:
space:
mode:
Diffstat (limited to 'lib/System')
-rw-r--r--lib/System/Path.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp
index 1504f0d831..1a6d030f89 100644
--- a/lib/System/Path.cpp
+++ b/lib/System/Path.cpp
@@ -49,6 +49,37 @@ sys::IdentifyFileType(const char*magic, unsigned length) {
return UnknownFileType;
}
+bool
+Path::isArchive() const {
+ if (readable())
+ return hasMagicNumber("!<arch>\012");
+ return false;
+}
+
+bool
+Path::isDynamicLibrary() const {
+ if (readable())
+ return hasMagicNumber("\177ELF");
+ return false;
+}
+
+Path
+Path::FindLibrary(std::string& name) {
+ std::vector<sys::Path> LibPaths;
+ GetSystemLibraryPaths(LibPaths);
+ for (unsigned i = 0; i < LibPaths.size(); ++i) {
+ sys::Path FullPath(LibPaths[i]);
+ FullPath.appendFile("lib" + name + LTDL_SHLIB_EXT);
+ if (FullPath.isDynamicLibrary())
+ return FullPath;
+ FullPath.elideSuffix();
+ FullPath.appendSuffix("a");
+ if (FullPath.isArchive())
+ return FullPath;
+ }
+ return sys::Path();
+}
+
}
// Include the truly platform-specific parts of this class.