From 2d6481cc2a168c4a867f8046119607f72552ef31 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 29 Dec 2003 21:35:05 +0000 Subject: Factor FDHandle out of the bytecode reader into the FileUtilities.h support routines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10642 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Reader/ReaderWrappers.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'lib/Bytecode/Reader') diff --git a/lib/Bytecode/Reader/ReaderWrappers.cpp b/lib/Bytecode/Reader/ReaderWrappers.cpp index 291ad87..bc3cbbd 100644 --- a/lib/Bytecode/Reader/ReaderWrappers.cpp +++ b/lib/Bytecode/Reader/ReaderWrappers.cpp @@ -16,12 +16,13 @@ #include "ReaderInternals.h" #include "llvm/Module.h" #include "llvm/Instructions.h" +#include "Support/FileUtilities.h" #include "Support/StringExtras.h" #include "Config/fcntl.h" -#include -#include #include "Config/unistd.h" #include "Config/sys/mman.h" +#include +#include using namespace llvm; //===----------------------------------------------------------------------===// @@ -29,19 +30,6 @@ using namespace llvm; // namespace { - /// FDHandle - Simple handle class to make sure a file descriptor gets closed - /// when the object is destroyed. - /// - class FDHandle { - int FD; - public: - FDHandle(int fd) : FD(fd) {} - operator int() const { return FD; } - ~FDHandle() { - if (FD != -1) close(FD); - } - }; - /// BytecodeFileReader - parses a bytecode file from a file /// class BytecodeFileReader : public BytecodeParser { @@ -63,7 +51,7 @@ static std::string ErrnoMessage (int savedErrNum, std::string descr) { } BytecodeFileReader::BytecodeFileReader(const std::string &Filename) { - FDHandle FD = open(Filename.c_str(), O_RDONLY); + FDHandle FD(open(Filename.c_str(), O_RDONLY)); if (FD == -1) throw ErrnoMessage(errno, "open '" + Filename + "'"); -- cgit v1.1