diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:16:21 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:16:21 +0200 |
commit | 88a2d0007db222c339f0b6a17794a2014a241892 (patch) | |
tree | 75105ef49b3a52b7ee176a1ad480e7652e49825f /zen/privilege.h | |
parent | 4.2 (diff) | |
download | FreeFileSync-88a2d0007db222c339f0b6a17794a2014a241892.tar.gz FreeFileSync-88a2d0007db222c339f0b6a17794a2014a241892.tar.bz2 FreeFileSync-88a2d0007db222c339f0b6a17794a2014a241892.zip |
4.3
Diffstat (limited to 'zen/privilege.h')
-rw-r--r-- | zen/privilege.h | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/zen/privilege.h b/zen/privilege.h index 4545aac7..88fc8992 100644 --- a/zen/privilege.h +++ b/zen/privilege.h @@ -7,57 +7,12 @@ #ifndef PRIVILEGE_H_INCLUDED #define PRIVILEGE_H_INCLUDED -#include <map> -#include "zstring.h" #include "file_error.h" #include "win.h" //includes "windows.h" namespace zen { -#ifdef FFS_WIN -class Privileges -{ -public: - static Privileges& getInstance(); - - void ensureActive(LPCTSTR privilege) //throw FileError - { - if (activePrivileges.find(privilege) != activePrivileges.end()) - return; //privilege already active - - if (privilegeIsActive(privilege)) //privilege was already active before starting this tool - activePrivileges.insert(std::make_pair(privilege, false)); - else - { - setPrivilege(privilege, true); - activePrivileges.insert(std::make_pair(privilege, true)); - } - } - -private: - Privileges() {} - Privileges(Privileges&); - void operator=(Privileges&); - - ~Privileges() //clean up: deactivate all privileges that have been activated by this application - { - for (PrivBuffType::const_iterator i = activePrivileges.begin(); i != activePrivileges.end(); ++i) - try - { - if (i->second) - Privileges::setPrivilege(i->first.c_str(), false); - } - catch (...) {} - } - - static bool privilegeIsActive(LPCTSTR privilege); //throw FileError - static void setPrivilege(LPCTSTR privilege, bool enable); //throw FileError - - typedef std::map<Zstring, bool> PrivBuffType; //bool: enabled by this application - - PrivBuffType activePrivileges; -}; -#endif +void activatePrivilege(LPCTSTR privilege); //throw FileError; thread-safe!!! } |