1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 // ============================================================
11 // Implements the Variables class
13 // ============================================================
15 #include "variables.hpp"
19 namespace BINDER_SPACE
21 #ifdef FEATURE_VERSIONING_LOG
24 HRESULT CheckFileExistence(LPCWSTR pwzFile, LPDWORD pdwAttrib)
29 _ASSERTE(pwzFile && pdwAttrib);
33 dwRet = WszGetFileAttributes(pwzFile);
34 if (dwRet == INVALID_FILE_ATTRIBUTES)
36 hr = HRESULT_FROM_GetLastError();
38 if ((hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) ||
39 (hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)))
41 GO_WITH_HRESULT(S_FALSE);
47 GO_WITH_HRESULT(S_OK);
54 #endif // FEATURE_VERSIONING_LOG
56 Variables *g_BinderVariables = NULL;
58 Variables::Variables()
63 Variables::~Variables()
68 HRESULT Variables::Init()
74 // ApplicationContext string constants
76 // AssemblyBinder string constants
77 httpURLPrefix.SetLiteral(W("http://"));
79 // AssemblyName string constants
80 architectureMSIL.SetLiteral(W("MSIL"));
81 architectureX86.SetLiteral(W("x86"));
82 architectureAMD64.SetLiteral(W("AMD64"));
83 architectureARM.SetLiteral(W("ARM"));
84 architectureARM64.SetLiteral(W("ARM64"));
85 cultureNeutral.SetLiteral(W("neutral"));
86 mscorlib.SetLiteral(CoreLibName_W);
90 #ifdef FEATURE_VERSIONING_LOG
91 REGUTIL::CORConfigLevel kCorConfigLevel =
92 static_cast<REGUTIL::CORConfigLevel>(REGUTIL::COR_CONFIG_ENV |
93 REGUTIL::COR_CONFIG_FUSION);
95 DWORD dwLoggingNeeded = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::EXTERNAL_ForceLog,
99 fLoggingNeeded = (dwLoggingNeeded ? TRUE : FALSE);
101 NewArrayHolder<WCHAR> pwzLogDirectory = REGUTIL::GetConfigString_DontUse_(CLRConfig::INTERNAL_LogPath,
104 FALSE /* fUsePerfCache */);
106 // When no directory is specified, we can't log.
107 if (pwzLogDirectory == NULL)
109 fLoggingNeeded = FALSE;
115 // If we do not get a regular directory, then we can't log either
116 hr = CheckFileExistence(pwzLogDirectory, &dwAttr);
117 if ((hr == S_OK) && ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0))
119 logPath.Set(pwzLogDirectory);
123 // Any failure here simply yields no logging.
125 fLoggingNeeded = FALSE;
128 #endif // FEATURE_VERSIONING_LOG
130 EX_CATCH_HRESULT(hr);