aboutsummaryrefslogtreecommitdiff
path: root/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
commit1fce09125cb46c91407668ca29915c450a482811 (patch)
tree9a221a439d7dc3ec57b8fa6cf345b90b6198d883 /lib/System/Unix/Path.cpp
parent357cf5439a5e0ad49245dc75798b6490d67834fd (diff)
Path::get -> Path::toString
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18785 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix/Path.cpp')
-rw-r--r--lib/System/Unix/Path.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/System/Unix/Path.cpp b/lib/System/Unix/Path.cpp
index 5d2a4b688c..d3e4d96a83 100644
--- a/lib/System/Unix/Path.cpp
+++ b/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;
}