2004-12-23 21:16:46 +00:00
|
|
|
//===- lib/Debugger/FDHandle.cpp - File Descriptor Handle -----------------===//
|
2005-04-21 22:36:52 +00:00
|
|
|
//
|
2004-12-22 10:24:55 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 22:36:52 +00:00
|
|
|
//
|
2004-12-22 10:24:55 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2004-12-23 21:16:46 +00:00
|
|
|
// This file implements a class for ensuring that Unix file handles get closed.
|
2004-12-22 10:24:55 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "FDHandle.h"
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// FDHandle class implementation
|
|
|
|
//
|
|
|
|
|
|
|
|
FDHandle::~FDHandle() throw() {
|
2005-04-21 22:36:52 +00:00
|
|
|
if (FD != -1)
|
2004-12-22 10:24:55 +00:00
|
|
|
::close(FD);
|
|
|
|
}
|
|
|
|
|
|
|
|
FDHandle &FDHandle::operator=(int fd) throw() {
|
2005-04-21 22:36:52 +00:00
|
|
|
if (FD != -1)
|
2004-12-22 10:24:55 +00:00
|
|
|
::close(FD);
|
|
|
|
FD = fd;
|
|
|
|
return *this;
|
|
|
|
}
|