summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-11-09 20:27:23 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-11-09 20:27:23 +0000
commit202eaeb2725da948c0dabd87718c3b56368c44eb (patch)
tree1609667498c7c5e099b399aa1dc4ce31a3b4ddf9
parentfb1f7357c23d1e9d01299df2ec45147e6a0971fb (diff)
downloadbcm5719-llvm-202eaeb2725da948c0dabd87718c3b56368c44eb.tar.gz
bcm5719-llvm-202eaeb2725da948c0dabd87718c3b56368c44eb.zip
Fix isBytecodeFile to correctly recognized compressed bytecode too.
llvm-svn: 17655
-rw-r--r--llvm/lib/System/Win32/Path.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/System/Win32/Path.cpp b/llvm/lib/System/Win32/Path.cpp
index e22b0354b7e..08a3d402e88 100644
--- a/llvm/lib/System/Win32/Path.cpp
+++ b/llvm/lib/System/Win32/Path.cpp
@@ -242,10 +242,13 @@ bool Path::hasMagicNumber(const std::string &Magic) const {
bool
Path::isBytecodeFile() const {
- if (readable()) {
- return hasMagicNumber("llvm");
- }
- return false;
+ char buffer[ 4];
+ buffer[0] = 0;
+ std::ifstream f(path.c_str());
+ f.read(buffer, 4);
+ if (f.bad())
+ ThrowErrno("can't read file signature");
+ return 0 == memcmp(buffer,"llvc",4) || 0 == memcmp(buffer,"llvm",4);
}
bool
OpenPOWER on IntegriCloud