[llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Dec 29 15:36:11 PST 2003
Changes in directory llvm/lib/Support:
FileUtilities.cpp updated: 1.14 -> 1.15
---
Log message:
Factor FDHandle out of the bytecode reader into the FileUtilities.h support
routines.
---
Diffs of the changes: (+23 -0)
Index: llvm/lib/Support/FileUtilities.cpp
diff -u llvm/lib/Support/FileUtilities.cpp:1.14 llvm/lib/Support/FileUtilities.cpp:1.15
--- llvm/lib/Support/FileUtilities.cpp:1.14 Sun Dec 14 15:35:53 2003
+++ llvm/lib/Support/FileUtilities.cpp Mon Dec 29 15:35:05 2003
@@ -194,3 +194,26 @@
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;
+}
More information about the llvm-commits
mailing list