diff options
author | Chris Lattner <sabre@nondot.org> | 2003-12-29 21:35:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-12-29 21:35:05 +0000 |
commit | a462161f9c7fada0f60903e3cd06899ad1a6fa70 (patch) | |
tree | 22b0a138b88d3f147d259fddf1227efe18b1358a /llvm/lib/Bytecode/Reader | |
parent | dca358f6ae1e91667a4a8ed82f5b17c61a0a5252 (diff) | |
download | bcm5719-llvm-a462161f9c7fada0f60903e3cd06899ad1a6fa70.tar.gz bcm5719-llvm-a462161f9c7fada0f60903e3cd06899ad1a6fa70.zip |
Factor FDHandle out of the bytecode reader into the FileUtilities.h support
routines.
llvm-svn: 10642
Diffstat (limited to 'llvm/lib/Bytecode/Reader')
-rw-r--r-- | llvm/lib/Bytecode/Reader/ReaderWrappers.cpp | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp b/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp index 291ad873443..bc3cbbd3309 100644 --- a/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp +++ b/llvm/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 <sys/stat.h> -#include <cerrno> #include "Config/unistd.h" #include "Config/sys/mman.h" +#include <sys/stat.h> +#include <cerrno> 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 + "'"); |