[llvm-commits] CVS: llvm/lib/System/Path.cpp
Reid Spencer
reid at x10sys.com
Sun Dec 12 19:00:50 PST 2004
Changes in directory llvm/lib/System:
Path.cpp updated: 1.9 -> 1.10
---
Log message:
For PR351: http://llvm.cs.uiuc.edu/PR351 : \
* Move generic isArchive method here from Unix/Path.cpp \
* Implement isDynamicLibrary \
* Implement FindLibrary for Linker
---
Diffs of the changes: (+31 -0)
Index: llvm/lib/System/Path.cpp
diff -u llvm/lib/System/Path.cpp:1.9 llvm/lib/System/Path.cpp:1.10
--- llvm/lib/System/Path.cpp:1.9 Sun Nov 14 17:26:18 2004
+++ llvm/lib/System/Path.cpp Sun Dec 12 21:00:39 2004
@@ -49,6 +49,37 @@
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.
More information about the llvm-commits
mailing list