summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix/Path.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-12-11 00:14:15 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-12-11 00:14:15 +0000
commit5ccfd5a48bf5d6e27ce0f38fac107d9095704767 (patch)
tree3ccb7b879e901d06d346fd8f6c2d9175c1408e4f /llvm/lib/System/Unix/Path.cpp
parenteef4420578b93f4024275096908719fc458b4a03 (diff)
downloadbcm5719-llvm-5ccfd5a48bf5d6e27ce0f38fac107d9095704767.tar.gz
bcm5719-llvm-5ccfd5a48bf5d6e27ce0f38fac107d9095704767.zip
Path::get -> Path::toString
llvm-svn: 18785
Diffstat (limited to 'llvm/lib/System/Unix/Path.cpp')
-rw-r--r--llvm/lib/System/Unix/Path.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/System/Unix/Path.cpp b/llvm/lib/System/Unix/Path.cpp
index 5d2a4b688c4..d3e4d96a83e 100644
--- a/llvm/lib/System/Unix/Path.cpp
+++ b/llvm/lib/System/Unix/Path.cpp
@@ -21,7 +21,6 @@
#include "Unix.h"
#include <sys/stat.h>
#include <fcntl.h>
-#include <fstream>
#include <utime.h>
#include <dirent.h>
@@ -192,10 +191,13 @@ bool
Path::isBytecodeFile() const {
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");
+ int fd = ::open(path.c_str(),O_RDONLY);
+ if (fd < 0)
+ return false;
+ ssize_t bytes_read = ::read(fd, buffer, 4);
+ ::close(fd);
+ if (4 != bytes_read)
+ return false;
return (buffer[0] == 'l' && buffer[1] == 'l' && buffer[2] == 'v' &&
(buffer[3] == 'c' || buffer[3] == 'm'));
@@ -522,7 +524,8 @@ bool
Path::renameFile(const Path& newName) {
if (!isFile()) return false;
if (0 != rename(path.c_str(), newName.c_str()))
- ThrowErrno(std::string("can't rename ") + path + " as " + newName.get());
+ ThrowErrno(std::string("can't rename ") + path + " as " +
+ newName.toString());
return true;
}
OpenPOWER on IntegriCloud