2004-12-23 22:16:46 +01:00
|
|
|
//===- lib/Debugger/FDHandle.cpp - File Descriptor Handle -----------------===//
|
2005-04-22 00:36:52 +02:00
|
|
|
//
|
2004-12-22 11:24:55 +01: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-22 00:36:52 +02:00
|
|
|
//
|
2004-12-22 11:24:55 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2004-12-23 22:16:46 +01:00
|
|
|
// This file implements a class for ensuring that Unix file handles get closed.
|
2004-12-22 11:24:55 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "FDHandle.h"
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// FDHandle class implementation
|
|
|
|
//
|
|
|
|
|
|
|
|
FDHandle::~FDHandle() throw() {
|
2005-04-22 00:36:52 +02:00
|
|
|
if (FD != -1)
|
2004-12-22 11:24:55 +01:00
|
|
|
::close(FD);
|
|
|
|
}
|
|
|
|
|
|
|
|
FDHandle &FDHandle::operator=(int fd) throw() {
|
2005-04-22 00:36:52 +02:00
|
|
|
if (FD != -1)
|
2004-12-22 11:24:55 +01:00
|
|
|
::close(FD);
|
|
|
|
FD = fd;
|
|
|
|
return *this;
|
|
|
|
}
|