aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Reader/ReaderWrappers.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-12-30 07:40:35 +0000
committerChris Lattner <sabre@nondot.org>2003-12-30 07:40:35 +0000
commitb70abe1c5adaf26e8d73d9aa4e5c76ed830cc94e (patch)
treebd95bae8dfe50dde7189245c897ea962252dfb68 /lib/Bytecode/Reader/ReaderWrappers.cpp
parent316cb083d66a38cf5d5975b974099c879e126341 (diff)
Use new getFileSize function instead of sys/stat.h directly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10650 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/ReaderWrappers.cpp')
-rw-r--r--lib/Bytecode/Reader/ReaderWrappers.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/Bytecode/Reader/ReaderWrappers.cpp b/lib/Bytecode/Reader/ReaderWrappers.cpp
index bc3cbbd330..ef5e70d42b 100644
--- a/lib/Bytecode/Reader/ReaderWrappers.cpp
+++ b/lib/Bytecode/Reader/ReaderWrappers.cpp
@@ -21,7 +21,6 @@
#include "Config/fcntl.h"
#include "Config/unistd.h"
#include "Config/sys/mman.h"
-#include <sys/stat.h>
#include <cerrno>
using namespace llvm;
@@ -51,17 +50,15 @@ static std::string ErrnoMessage (int savedErrNum, std::string descr) {
}
BytecodeFileReader::BytecodeFileReader(const std::string &Filename) {
+ Length = getFileSize(Filename);
+ if (Length == -1)
+ throw ErrnoMessage(errno, "stat '" + Filename + "'");
+
FDHandle FD(open(Filename.c_str(), O_RDONLY));
if (FD == -1)
throw ErrnoMessage(errno, "open '" + Filename + "'");
- // Stat the file to get its length...
- struct stat StatBuf;
- if (fstat(FD, &StatBuf) == -1 || StatBuf.st_size == 0)
- throw ErrnoMessage(errno, "stat '" + Filename + "'");
-
// mmap in the file all at once...
- Length = StatBuf.st_size;
Buffer = (unsigned char*)mmap(0, Length, PROT_READ, MAP_PRIVATE, FD, 0);
if (Buffer == (unsigned char*)MAP_FAILED)