fusion: Add support for ASM_CACHE_ROOT_EX in GetCachePath.

This commit is contained in:
Hans Leidekker 2012-05-21 11:25:12 +02:00 committed by Alexandre Julliard
parent 08cbe5d26f
commit f408fa83ee
2 changed files with 27 additions and 27 deletions

View File

@ -90,32 +90,26 @@ static HRESULT get_corversion(LPWSTR version, DWORD size)
HRESULT WINAPI GetCachePath(ASM_CACHE_FLAGS dwCacheFlags, LPWSTR pwzCachePath, HRESULT WINAPI GetCachePath(ASM_CACHE_FLAGS dwCacheFlags, LPWSTR pwzCachePath,
PDWORD pcchPath) PDWORD pcchPath)
{ {
WCHAR path[MAX_PATH]; static const WCHAR assembly[] = {'\\','a','s','s','e','m','b','l','y',0};
WCHAR windir[MAX_PATH]; static const WCHAR gac[] = {'\\','G','A','C',0};
WCHAR version[MAX_PATH]; static const WCHAR nativeimg[] = {'N','a','t','i','v','e','I','m','a','g','e','s','_',0};
DWORD len; static const WCHAR dotnet[] = {'\\','M','i','c','r','o','s','o','f','t','.','N','E','T',0};
HRESULT hr = S_OK;
static const WCHAR backslash[] = {'\\',0};
static const WCHAR assembly[] = {'a','s','s','e','m','b','l','y',0};
static const WCHAR gac[] = {'G','A','C',0};
static const WCHAR nativeimg[] = {
'N','a','t','i','v','e','I','m','a','g','e','s','_',0};
#ifdef _WIN64 #ifdef _WIN64
static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','6','4',0}; static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','6','4',0};
#else #else
static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','3','2',0}; static const WCHAR zapfmt[] = {'%','s','\\','%','s','\\','%','s','%','s','_','3','2',0};
#endif #endif
WCHAR path[MAX_PATH], windir[MAX_PATH], version[MAX_PATH];
DWORD len;
HRESULT hr = S_OK;
TRACE("(%08x, %p, %p)\n", dwCacheFlags, pwzCachePath, pcchPath); TRACE("(%08x, %p, %p)\n", dwCacheFlags, pwzCachePath, pcchPath);
if (!pcchPath) if (!pcchPath)
return E_INVALIDARG; return E_INVALIDARG;
GetWindowsDirectoryW(windir, MAX_PATH); len = GetWindowsDirectoryW(windir, MAX_PATH);
lstrcpyW(path, windir); strcpyW(path, windir);
lstrcatW(path, backslash);
lstrcatW(path, assembly);
switch (dwCacheFlags) switch (dwCacheFlags)
{ {
@ -125,37 +119,42 @@ HRESULT WINAPI GetCachePath(ASM_CACHE_FLAGS dwCacheFlags, LPWSTR pwzCachePath,
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
sprintfW(path, zapfmt, windir, assembly, nativeimg, version); len = sprintfW(path, zapfmt, windir, assembly + 1, nativeimg, version);
break; break;
} }
case ASM_CACHE_GAC: case ASM_CACHE_GAC:
{ {
lstrcatW(path, backslash); strcpyW(path + len, assembly);
lstrcatW(path, gac); len += sizeof(assembly)/sizeof(WCHAR) - 1;
strcpyW(path + len, gac);
len += sizeof(gac)/sizeof(WCHAR) - 1;
break; break;
} }
case ASM_CACHE_DOWNLOAD: case ASM_CACHE_DOWNLOAD:
{ {
FIXME("Download cache not implemented\n"); FIXME("Download cache not implemented\n");
return E_FAIL; return E_FAIL;
} }
case ASM_CACHE_ROOT: case ASM_CACHE_ROOT:
break; /* already set */ strcpyW(path + len, assembly);
len += sizeof(assembly)/sizeof(WCHAR) - 1;
break;
case ASM_CACHE_ROOT_EX:
strcpyW(path + len, dotnet);
len += sizeof(dotnet)/sizeof(WCHAR) - 1;
strcpyW(path + len, assembly);
len += sizeof(assembly)/sizeof(WCHAR) - 1;
break;
default: default:
return E_INVALIDARG; return E_INVALIDARG;
} }
len = lstrlenW(path) + 1; len++;
if (*pcchPath <= len || !pwzCachePath) if (*pcchPath <= len || !pwzCachePath)
hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
else if (pwzCachePath) else if (pwzCachePath)
lstrcpyW(pwzCachePath, path); strcpyW(pwzCachePath, path);
*pcchPath = len; *pcchPath = len;
return hr; return hr;
} }

View File

@ -28,7 +28,8 @@ typedef enum
ASM_CACHE_ZAP = 0x1, ASM_CACHE_ZAP = 0x1,
ASM_CACHE_GAC = 0x2, ASM_CACHE_GAC = 0x2,
ASM_CACHE_DOWNLOAD = 0x4, ASM_CACHE_DOWNLOAD = 0x4,
ASM_CACHE_ROOT = 0x8 ASM_CACHE_ROOT = 0x8,
ASM_CACHE_ROOT_EX = 0x80
} ASM_CACHE_FLAGS; } ASM_CACHE_FLAGS;
typedef enum typedef enum