For PR351:
[oota-llvm.git] / lib / Debugger / FDHandle.cpp
1 //===- Support/FileUtilities.cpp - File System Utilities ------------------===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements a family of utility functions which are useful for doing
11 // various things with files.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "FDHandle.h"
16 #include <unistd.h>
17
18 using namespace llvm;
19
20 //===----------------------------------------------------------------------===//
21 // FDHandle class implementation
22 //
23
24 FDHandle::~FDHandle() throw() {
25   if (FD != -1) 
26     ::close(FD);
27 }
28
29 FDHandle &FDHandle::operator=(int fd) throw() {
30   if (FD != -1) 
31     ::close(FD);
32   FD = fd;
33   return *this;
34 }