Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/shared/Utils.cpp

Issue 6202981292703744: Whole installer (Closed)
Patch Set: Created June 24, 2014, 7:27 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <memory> 1 #include <memory>
2 #include <stdexcept> 2 #include <stdexcept>
3 #include <vector> 3 #include <vector>
4 4
5 #include <Windows.h> 5 #include <Windows.h>
6 #include <ShlObj.h> 6 #include <ShlObj.h>
7 7
8 #include "Utils.h" 8 #include "Utils.h"
9 9
10 namespace 10 namespace
11 { 11 {
12 // See http://blogs.msdn.com/b/oldnewthing/archive/2004/10/25/247180.aspx 12 // See http://blogs.msdn.com/b/oldnewthing/archive/2004/10/25/247180.aspx
13 EXTERN_C IMAGE_DOS_HEADER __ImageBase; 13 EXTERN_C IMAGE_DOS_HEADER __ImageBase;
14 14
15 std::wstring appDataPath; 15 std::wstring appDataPath;
16 16
17 } 17 }
18 18
19 bool IsWindowsVistaOrLater() 19 bool IsWindowsVistaOrLater()
20 { 20 {
21 OSVERSIONINFOEX osvi; 21 OSVERSIONINFOEX osvi;
22 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); 22 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
23 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 23 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
24 GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi)); 24 GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi));
25 return osvi.dwMajorVersion >= 6; 25 return osvi.dwMajorVersion >= 6;
26 } 26 }
27 27
28 bool IsAppContainersSupported()
29 {
30 //Try to allocate SID of AppContainer and see if it's succesful
31 PSID allAppContainersSid = 0;
32 SID_IDENTIFIER_AUTHORITY applicationAuthority = SECURITY_APP_PACKAGE_AUTHORITY ;
33 BOOL res = AllocateAndInitializeSid(&applicationAuthority,
34 SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT,
35 SECURITY_APP_PACKAGE_BASE_RID,
36 SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE,
37 0, 0, 0, 0, 0, 0,
38 &allAppContainersSid);
39
40 if (res == FALSE)
41 {
42 return false;
43 }
44 else
45 {
46 FreeSid(allAppContainersSid);
47 return true;
48 }
49 }
50
28 std::string ToUtf8String(const std::wstring& str) 51 std::string ToUtf8String(const std::wstring& str)
29 { 52 {
30 int length = static_cast<int>(str.size()); 53 int length = static_cast<int>(str.size());
31 if (length == 0) 54 if (length == 0)
32 return std::string(); 55 return std::string();
33 56
34 int utf8StringLength = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), length, 0, 0, 0, 0); 57 int utf8StringLength = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), length, 0, 0, 0, 0);
35 if (utf8StringLength == 0) 58 if (utf8StringLength == 0)
36 throw std::runtime_error("Failed to determine the required buffer size"); 59 throw std::runtime_error("Failed to determine the required buffer size");
37 60
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 135 }
113 136
114 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement) 137 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement)
115 { 138 {
116 size_t replaceStart = input.find(placeholder); 139 size_t replaceStart = input.find(placeholder);
117 if (replaceStart != std::string::npos) 140 if (replaceStart != std::string::npos)
118 { 141 {
119 input.replace(replaceStart, placeholder.length(), replacement); 142 input.replace(replaceStart, placeholder.length(), replacement);
120 } 143 }
121 } 144 }
OLDNEW
« build_release.py ('K') | « src/shared/Utils.h ('k') | test/CommunicationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld