[llvm-commits] CVS: llvm/lib/System/Unix/MappedFile.cpp Path.cpp Program.cpp Signals.cpp
Reid Spencer
reid at x10sys.com
Fri Dec 10 16:14:29 PST 2004
Changes in directory llvm/lib/System/Unix:
MappedFile.cpp updated: 1.6 -> 1.7
Path.cpp updated: 1.15 -> 1.16
Program.cpp updated: 1.5 -> 1.6
Signals.cpp updated: 1.3 -> 1.4
---
Log message:
Path::get -> Path::toString
---
Diffs of the changes: (+21 -15)
Index: llvm/lib/System/Unix/MappedFile.cpp
diff -u llvm/lib/System/Unix/MappedFile.cpp:1.6 llvm/lib/System/Unix/MappedFile.cpp:1.7
--- llvm/lib/System/Unix/MappedFile.cpp:1.6 Sun Nov 14 16:07:50 2004
+++ llvm/lib/System/Unix/MappedFile.cpp Fri Dec 10 18:14:15 2004
@@ -44,17 +44,17 @@
if (info_->fd_ < 0) {
delete info_;
info_ = 0;
- ThrowErrno(std::string("Can't open file: ") + path_.get());
+ ThrowErrno(std::string("Can't open file: ") + path_.toString());
}
struct stat sbuf;
if(::fstat(info_->fd_, &info_->sbuf_) < 0) {
::close(info_->fd_);
delete info_;
info_ = 0;
- ThrowErrno(std::string("Can't stat file: ") + path_.get());
+ ThrowErrno(std::string("Can't stat file: ") + path_.toString());
}
} else {
- throw std::string("Can't open file: ") + path_.get();
+ throw std::string("Can't open file: ") + path_.toString();
}
}
@@ -103,7 +103,7 @@
base_ = ::mmap(0, map_size, prot, flags, info_->fd_, 0);
if (base_ == MAP_FAILED)
- ThrowErrno(std::string("Can't map file:") + path_.get());
+ ThrowErrno(std::string("Can't map file:") + path_.toString());
}
return base_;
}
Index: llvm/lib/System/Unix/Path.cpp
diff -u llvm/lib/System/Unix/Path.cpp:1.15 llvm/lib/System/Unix/Path.cpp:1.16
--- llvm/lib/System/Unix/Path.cpp:1.15 Thu Dec 2 03:09:48 2004
+++ llvm/lib/System/Unix/Path.cpp Fri Dec 10 18:14:15 2004
@@ -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 @@
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 @@
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;
}
Index: llvm/lib/System/Unix/Program.cpp
diff -u llvm/lib/System/Unix/Program.cpp:1.5 llvm/lib/System/Unix/Program.cpp:1.6
--- llvm/lib/System/Unix/Program.cpp:1.5 Fri Nov 5 16:15:36 2004
+++ llvm/lib/System/Unix/Program.cpp Fri Dec 10 18:14:15 2004
@@ -81,7 +81,7 @@
Program::ExecuteAndWait(const Path& path,
const std::vector<std::string>& args) {
if (!path.executable())
- throw path.get() + " is not executable";
+ throw path.toString() + " is not executable";
#ifdef HAVE_SYS_WAIT_H
// Create local versions of the parameters that can be passed into execve()
@@ -98,7 +98,8 @@
switch (fork()) {
// An error occured: Return to the caller.
case -1:
- ThrowErrno(std::string("Couldn't execute program '") + path.get() + "'");
+ ThrowErrno(std::string("Couldn't execute program '") + path.toString() +
+ "'");
break;
// Child process: Execute the program.
@@ -116,13 +117,15 @@
// Parent process: Wait for the child process to terminate.
int status;
if ((::wait (&status)) == -1)
- ThrowErrno(std::string("Failed waiting for program '") + path.get() + "'");
+ ThrowErrno(std::string("Failed waiting for program '") + path.toString()
+ + "'");
// If the program exited normally with a zero exit status, return success!
if (WIFEXITED (status))
return WEXITSTATUS(status);
else if (WIFSIGNALED(status))
- throw std::string("Program '") + path.get() + "' received terminating signal.";
+ throw std::string("Program '") + path.toString() +
+ "' received terminating signal.";
else
return 0;
Index: llvm/lib/System/Unix/Signals.cpp
diff -u llvm/lib/System/Unix/Signals.cpp:1.3 llvm/lib/System/Unix/Signals.cpp:1.4
--- llvm/lib/System/Unix/Signals.cpp:1.3 Sun Nov 14 16:09:22 2004
+++ llvm/lib/System/Unix/Signals.cpp Fri Dec 10 18:14:15 2004
@@ -138,7 +138,7 @@
if (FilesToRemove == 0)
FilesToRemove = new std::vector<std::string>;
- FilesToRemove->push_back(Filename.get());
+ FilesToRemove->push_back(Filename.toString());
std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
std::for_each(KillSigs, KillSigsEnd, RegisterHandler);
More information about the llvm-commits
mailing list