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/Support/FileUtilities.cpp | |
| 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/Support/FileUtilities.cpp')
| -rw-r--r-- | llvm/lib/Support/FileUtilities.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp index e6abc8fb40e..02b4edd5573 100644 --- a/llvm/lib/Support/FileUtilities.cpp +++ b/llvm/lib/Support/FileUtilities.cpp @@ -194,3 +194,26 @@ bool llvm::MakeFileExecutable(const std::string &Filename) { bool llvm::MakeFileReadable(const std::string &Filename) { return AddPermissionsBits(Filename, 0444); } + +//===----------------------------------------------------------------------===// +// FDHandle class implementation +// + +FDHandle::~FDHandle() { + if (FD != -1) close(FD); +} + +FDHandle &FDHandle::operator=(int fd) { + if (FD != -1) close(FD); + FD = fd; + return *this; +} + + +/// take - Take ownership of the file descriptor away from the FDHandle +/// object, so that the file is not closed when the FDHandle is destroyed. +int FDHandle::take() { + int Ret = FD; + FD = -1; + return Ret; +} |

