Module: wine Branch: master Commit: 5f83069bd852be706d773f934b876c5b843b4578 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=5f83069bd852be706d773f93...
Author: Mike McCormack mike@codeweavers.com Date: Fri Sep 8 16:20:46 2006 +0900
msi: Split code to create a random package name into a separate function.
---
dlls/msi/action.c | 63 ++++++++++++++++++++++++++++------------------------- 1 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/dlls/msi/action.c b/dlls/msi/action.c index da7d7e8..b309509 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -3487,32 +3487,25 @@ end: return rc; }
-static UINT msi_make_package_local( MSIPACKAGE *package, HKEY hkey ) +static UINT msi_get_local_package_name( LPWSTR path ) { - static const WCHAR installerPathFmt[] = { - '%','s','\','I','n','s','t','a','l','l','e','r','\',0}; - static const WCHAR fmt[] = { - '%','s','\', - 'I','n','s','t','a','l','l','e','r','\', - '%','x','.','m','s','i',0}; - static const WCHAR szOriginalDatabase[] = - {'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0}; - WCHAR windir[MAX_PATH], path[MAX_PATH], packagefile[MAX_PATH]; - INT num, start; - LPWSTR msiFilePath; - BOOL r; - - /* copy the package locally */ - num = GetTickCount() & 0xffff; - if (!num) - num = 1; - start = num; - GetWindowsDirectoryW( windir, MAX_PATH ); - snprintfW( packagefile, MAX_PATH, fmt, windir, num ); - do + static const WCHAR szInstaller[] = { + '\','I','n','s','t','a','l','l','e','r','\',0}; + static const WCHAR fmt[] = { '%','x','.','m','s','i',0}; + DWORD time, len, i; + HANDLE handle; + + time = GetTickCount(); + GetWindowsDirectoryW( path, MAX_PATH ); + lstrcatW( path, szInstaller ); + CreateDirectoryW( path, NULL ); + + len = lstrlenW(path); + for (i=0; i<0x10000; i++) { - HANDLE handle = CreateFileW(packagefile,GENERIC_WRITE, 0, NULL, - CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 ); + snprintfW( &path[len], MAX_PATH - len, fmt, (time+i)&0xffff ); + handle = CreateFileW( path, GENERIC_WRITE, 0, NULL, + CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 ); if (handle != INVALID_HANDLE_VALUE) { CloseHandle(handle); @@ -3520,13 +3513,23 @@ static UINT msi_make_package_local( MSIP } if (GetLastError() != ERROR_FILE_EXISTS && GetLastError() != ERROR_SHARING_VIOLATION) - break; - if (!(++num & 0xffff)) num = 1; - sprintfW(packagefile,fmt,num); - } while (num != start); + return ERROR_FUNCTION_FAILED; + }
- snprintfW( path, MAX_PATH, installerPathFmt, windir ); - create_full_pathW(path); + return ERROR_SUCCESS; +} + +static UINT msi_make_package_local( MSIPACKAGE *package, HKEY hkey ) +{ + static const WCHAR szOriginalDatabase[] = + {'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0}; + WCHAR packagefile[MAX_PATH]; + LPWSTR msiFilePath; + UINT r; + + r = msi_get_local_package_name( packagefile ); + if (r != ERROR_SUCCESS) + return r;
TRACE("Copying to local package %s\n",debugstr_w(packagefile));