2 * Copyright (C) 2005-2008 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 #include "AutoPtrHandle.h"
24 using namespace AUTOPTR
;
26 CAutoPtrHandle::CAutoPtrHandle(HANDLE hHandle
)
30 CAutoPtrHandle::~CAutoPtrHandle(void)
35 CAutoPtrHandle::operator HANDLE()
40 void CAutoPtrHandle::attach(HANDLE hHandle
)
46 HANDLE
CAutoPtrHandle::release()
48 HANDLE hTmp
= m_hHandle
;
49 m_hHandle
= INVALID_HANDLE_VALUE
;
53 void CAutoPtrHandle::Cleanup()
57 CloseHandle(m_hHandle
);
58 m_hHandle
= INVALID_HANDLE_VALUE
;
62 bool CAutoPtrHandle::isValid() const
64 if ( INVALID_HANDLE_VALUE
!= m_hHandle
)
68 void CAutoPtrHandle::reset()
73 //-------------------------------------------------------------------------------
74 CAutoPtrFind ::CAutoPtrFind(HANDLE hHandle
)
75 : CAutoPtrHandle(hHandle
)
77 CAutoPtrFind::~CAutoPtrFind(void)
82 void CAutoPtrFind::Cleanup()
87 m_hHandle
= INVALID_HANDLE_VALUE
;
91 //-------------------------------------------------------------------------------
92 CAutoPtrSocket::CAutoPtrSocket(SOCKET hSocket
)
96 CAutoPtrSocket::~CAutoPtrSocket(void)
101 CAutoPtrSocket::operator SOCKET()
106 void CAutoPtrSocket::attach(SOCKET hSocket
)
112 SOCKET
CAutoPtrSocket::release()
114 SOCKET hTmp
= m_hSocket
;
115 m_hSocket
= INVALID_SOCKET
;
119 void CAutoPtrSocket::Cleanup()
123 closesocket(m_hSocket
);
124 m_hSocket
= INVALID_SOCKET
;
128 bool CAutoPtrSocket::isValid() const
130 if ( INVALID_SOCKET
!= m_hSocket
)
134 void CAutoPtrSocket::reset()