summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Path.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-12-13 03:00:39 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-12-13 03:00:39 +0000
commit66b818286620e73faad98bd35682ed9907258370 (patch)
tree39d5b17a4ff52e59f9089b302f1b904630fb6a78 /llvm/lib/System/Path.cpp
parent4a23d3f8e584796f3663477245fe1eef625657e5 (diff)
downloadbcm5719-llvm-66b818286620e73faad98bd35682ed9907258370.tar.gz
bcm5719-llvm-66b818286620e73faad98bd35682ed9907258370.zip
For PR351: \
* Move generic isArchive method here from Unix/Path.cpp \ * Implement isDynamicLibrary \ * Implement FindLibrary for Linker llvm-svn: 18861
Diffstat (limited to 'llvm/lib/System/Path.cpp')
-rw-r--r--llvm/lib/System/Path.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/llvm/lib/System/Path.cpp b/llvm/lib/System/Path.cpp
index 1504f0d8312..1a6d030f896 100644
--- a/llvm/lib/System/Path.cpp
+++ b/llvm/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.
OpenPOWER on IntegriCloud