other-licenses/7zstub/src/Windows/Handle.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Windows/Handle.h
michael@0 2
michael@0 3 #ifndef __WINDOWS_HANDLE_H
michael@0 4 #define __WINDOWS_HANDLE_H
michael@0 5
michael@0 6 namespace NWindows {
michael@0 7
michael@0 8 class CHandle
michael@0 9 {
michael@0 10 protected:
michael@0 11 HANDLE _handle;
michael@0 12 public:
michael@0 13 operator HANDLE() { return _handle; }
michael@0 14 CHandle(): _handle(NULL) {}
michael@0 15 ~CHandle() { Close(); }
michael@0 16 bool Close()
michael@0 17 {
michael@0 18 if (_handle == NULL)
michael@0 19 return true;
michael@0 20 if (!::CloseHandle(_handle))
michael@0 21 return false;
michael@0 22 _handle = NULL;
michael@0 23 return true;
michael@0 24 }
michael@0 25 void Attach(HANDLE handle)
michael@0 26 { _handle = handle; }
michael@0 27 HANDLE Detach()
michael@0 28 {
michael@0 29 HANDLE handle = _handle;
michael@0 30 _handle = NULL;
michael@0 31 return handle;
michael@0 32 }
michael@0 33 };
michael@0 34
michael@0 35 }
michael@0 36
michael@0 37 #endif

mercurial