Changeset 10296 for trunk/src/version/install.c
- Timestamp:
- Oct 24, 2003, 4:47:25 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/version/install.c
r2373 r10296 1 /* $Id: install.c,v 1.2 2000-01-08 14:27:33 sandervl Exp $ */ 2 /* 3 * Implementation of VERSION.DLL - File Installer routines (Wine 991212) 4 * 1 /* 2 * Implementation of VERSION.DLL - File Installer routines 3 * 5 4 * Copyright 1996,1997 Marcus Meissner 6 5 * Copyright 1997 David Cuthbert 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * 21 * TODO 22 * o Check the installation functions. 7 23 */ 8 24 9 25 #include <stdlib.h> 26 #include <stdarg.h> 27 #include <stdio.h> 10 28 #include <string.h> 11 29 12 30 #include "windef.h" 31 #include "winbase.h" 13 32 #include "winver.h" 14 #include "wine/winestring.h" 33 #include "winnls.h" 34 #include "wine/unicode.h" 15 35 #include "winerror.h" 16 #include "heap.h"17 36 #include "lzexpand.h" 18 #include "xmalloc.h" 19 #include "debugtools.h" 20 #include <misc.h> 21 22 DEFAULT_DEBUG_CHANNEL(ver) 37 #include "wine/debug.h" 38 39 WINE_DEFAULT_DEBUG_CHANNEL(ver); 23 40 24 41 25 42 /****************************************************************************** 26 * 27 * void ver_dstring( 28 * char const * prologue, 29 * char const * teststring, 30 * char const * epilogue ) 31 * 32 * This function will print via dprintf[_]ver to stddeb the prologue string, 33 * followed by the address of teststring and the string it contains if 34 * teststring is non-null or "(null)" otherwise, and then the epilogue 35 * string followed by a new line. 36 * 37 * Revision history 38 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 39 * Original implementation as dprintf[_]ver_string 40 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu) 41 * Fixed problem that caused bug with tools/make_debug -- renaming 42 * this function should fix the problem. 43 * 15-Feb-1998 Dimitrie Paun (dimi@cs.toronto.edu) 44 * Modified it to make it print the message using only one 45 * dprintf[_]ver call. 46 * 47 *****************************************************************************/ 48 49 static void ver_dstring( 50 char const * prologue, 51 char const * teststring, 52 char const * epilogue ) 53 { 54 TRACE("%s %p (\"%s\") %s\n", prologue, 55 (void const *) teststring, 56 teststring ? teststring : "(null)", 57 epilogue); 58 } 59 60 /****************************************************************************** 61 * 62 * int testFileExistence( 63 * char const * path, 64 * char const * file ) 43 * testFileExistenceA 65 44 * 66 45 * Tests whether a given path/file combination exists. If the file does … … 72 51 * Original implementation 73 52 * 74 *****************************************************************************/ 75 76 static int testFileExistence( 77 char const * path, 78 char const * file ) 53 */ 54 static int testFileExistenceA( char const * path, char const * file, BOOL excl ) 79 55 { 80 56 char filename[1024]; 81 57 int filenamelen; 82 58 OFSTRUCT fileinfo; 83 int retval;84 59 85 60 fileinfo.cBytes = sizeof(OFSTRUCT); … … 99 74 strcat(filename, file); 100 75 101 if(OpenFile(filename, &fileinfo, OF_EXIST) == HFILE_ERROR) 102 retval = 0; 103 else 104 retval = 1; 105 106 return retval; 76 return (OpenFile(filename, &fileinfo, 77 OF_EXIST | (excl ? OF_SHARE_EXCLUSIVE : 0)) != HFILE_ERROR); 107 78 } 108 79 109 80 /****************************************************************************** 110 * 111 * int testFileExclusiveExistence( 112 * char const * path, 113 * char const * file ) 114 * 115 * Tests whether a given path/file combination exists and ensures that no 116 * other programs have handles to the given file. If the file does not 117 * exist or is open, the return value is zero. If it does exist, the 118 * return value is non-zero. 119 * 120 * Revision history 121 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 122 * Original implementation 123 * 124 *****************************************************************************/ 125 126 static int testFileExclusiveExistence( 127 char const * path, 128 char const * file ) 81 * testFileExistenceW 82 */ 83 static int testFileExistenceW( const WCHAR *path, const WCHAR *file, BOOL excl ) 129 84 { 130 char filename[1024];131 int filenamelen;132 OFSTRUCT fileinfo;133 int retval;85 char *filename; 86 DWORD pathlen, filelen; 87 int ret; 88 OFSTRUCT fileinfo; 134 89 135 90 fileinfo.cBytes = sizeof(OFSTRUCT); 136 91 137 strcpy(filename, path); 138 filenamelen = strlen(filename); 139 92 pathlen = WideCharToMultiByte( CP_ACP, 0, path, -1, NULL, 0, NULL, NULL ); 93 filelen = WideCharToMultiByte( CP_ACP, 0, file, -1, NULL, 0, NULL, NULL ); 94 filename = HeapAlloc( GetProcessHeap(), 0, pathlen+filelen+2 ); 95 96 WideCharToMultiByte( CP_ACP, 0, path, -1, filename, pathlen, NULL, NULL ); 140 97 /* Add a trailing \ if necessary */ 141 if (filenamelen) {142 if(filename[filenamelen - 1] != '\\') 143 strcat(filename, "\\");98 if (pathlen > 1) 99 { 100 if (filename[pathlen-2] != '\\') strcpy( &filename[pathlen-1], "\\" ); 144 101 } 145 102 else /* specify the current directory */ 146 strcpy(filename, ".\\"); 147 148 /* Create the full pathname */ 149 strcat(filename, file); 150 151 if(OpenFile(filename, &fileinfo, OF_EXIST | OF_SHARE_EXCLUSIVE) == 152 HFILE_ERROR) 153 retval = 0; 154 else 155 retval = 1; 156 157 return retval; 103 strcpy(filename, ".\\"); 104 105 WideCharToMultiByte( CP_ACP, 0, file, -1, filename+strlen(filename), filelen, NULL, NULL ); 106 107 ret = (OpenFile(filename, &fileinfo, 108 OF_EXIST | (excl ? OF_SHARE_EXCLUSIVE : 0)) != HFILE_ERROR); 109 HeapFree( GetProcessHeap(), 0, filename ); 110 return ret; 158 111 } 159 112 160 113 /***************************************************************************** 161 * 162 * VerFindFile() [VER.8]114 * VerFindFileA [VERSION.@] 115 * 163 116 * Determines where to install a file based on whether it locates another 164 117 * version of the file in the system. The values VerFindFile returns are … … 168 121 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 169 122 * Reimplementation of VerFindFile from original stub. 170 * 171 ****************************************************************************/ 172 173 /* VerFindFile32A [VERSION.5] */ 123 */ 174 124 DWORD WINAPI VerFindFileA( 175 125 UINT flags, … … 182 132 UINT *lpuDestDirLen ) 183 133 { 184 DWORD retval ;185 c har curDir[256];186 c har destDir[256];134 DWORD retval = 0; 135 const char *curDir; 136 const char *destDir; 187 137 unsigned int curDirSizeReq; 188 138 unsigned int destDirSizeReq; 189 190 retval = 0; 139 char systemDir[MAX_PATH]; 191 140 192 141 /* Print out debugging information */ 193 TRACE("called with parameters:\n" 194 "\tflags = %x", flags); 195 if(flags & VFFF_ISSHAREDFILE) 196 TRACE(" (VFFF_ISSHAREDFILE)\n"); 197 else 198 TRACE("\n"); 199 200 ver_dstring("\tlpszFilename = ", lpszFilename, ""); 201 ver_dstring("\tlpszWinDir = ", lpszWinDir, ""); 202 ver_dstring("\tlpszAppDir = ", lpszAppDir, ""); 203 204 TRACE("\tlpszCurDir = %p\n", lpszCurDir); 205 if(lpuCurDirLen) 206 TRACE("\tlpuCurDirLen = %p (%u)\n", 207 lpuCurDirLen, *lpuCurDirLen); 208 else 209 TRACE("\tlpuCurDirLen = (null)\n"); 210 211 TRACE("\tlpszDestDir = %p\n", lpszDestDir); 212 if(lpuDestDirLen) 213 TRACE("\tlpuDestDirLen = %p (%u)\n", 214 lpuDestDirLen, *lpuDestDirLen); 142 TRACE("flags = %x filename=%s windir=%s appdir=%s curdirlen=%p(%u) destdirlen=%p(%u)\n", 143 flags, debugstr_a(lpszFilename), debugstr_a(lpszWinDir), debugstr_a(lpszAppDir), 144 lpuCurDirLen, lpuCurDirLen ? *lpuCurDirLen : 0, 145 lpuDestDirLen, lpuDestDirLen ? *lpuDestDirLen : 0 ); 215 146 216 147 /* Figure out where the file should go; shared files default to the 217 148 system directory */ 218 149 219 strcpy(curDir, ""); 220 strcpy(destDir, ""); 221 222 if(flags & VFFF_ISSHAREDFILE) { 223 GetSystemDirectoryA(destDir, 256); 224 225 /* Were we given a filename? If so, try to find the file. */ 226 if(lpszFilename) { 227 if(testFileExistence(destDir, lpszFilename)) { 228 strcpy(curDir, destDir); 229 230 if(!testFileExclusiveExistence(destDir, lpszFilename)) 231 retval |= VFF_FILEINUSE; 232 } 233 else if(lpszAppDir && testFileExistence(lpszAppDir, 234 lpszFilename)) { 235 strcpy(curDir, lpszAppDir); 236 retval |= VFF_CURNEDEST; 237 238 if(!testFileExclusiveExistence(lpszAppDir, lpszFilename)) 239 retval |= VFF_FILEINUSE; 240 } 241 } 242 } 243 else if(!(flags & VFFF_ISSHAREDFILE)) { /* not a shared file */ 244 if(lpszAppDir) { 245 char systemDir[256]; 246 GetSystemDirectoryA(systemDir, 256); 247 248 strcpy(destDir, lpszAppDir); 249 250 if(lpszFilename) { 251 if(testFileExistence(lpszAppDir, lpszFilename)) { 252 strcpy(curDir, lpszAppDir); 253 254 if(!testFileExclusiveExistence(lpszAppDir, lpszFilename)) 255 retval |= VFF_FILEINUSE; 256 } 257 else if(testFileExistence(systemDir, lpszFilename)) { 258 strcpy(curDir, systemDir); 259 retval |= VFF_CURNEDEST; 260 261 if(!testFileExclusiveExistence(systemDir, lpszFilename)) 262 retval |= VFF_FILEINUSE; 263 } 264 } 265 } 266 } 150 GetSystemDirectoryA(systemDir, sizeof(systemDir)); 151 curDir = ""; 152 destDir = ""; 153 154 if(flags & VFFF_ISSHAREDFILE) 155 { 156 destDir = systemDir; 157 /* Were we given a filename? If so, try to find the file. */ 158 if(lpszFilename) 159 { 160 if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir; 161 else if(lpszAppDir && testFileExistenceA(lpszAppDir, lpszFilename, FALSE)) 162 { 163 curDir = lpszAppDir; 164 retval |= VFF_CURNEDEST; 165 } 166 } 167 } 168 else /* not a shared file */ 169 { 170 if(lpszAppDir) 171 { 172 destDir = lpszAppDir; 173 if(lpszFilename) 174 { 175 if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir; 176 else if(testFileExistenceA(systemDir, lpszFilename, FALSE)) 177 { 178 curDir = systemDir; 179 retval |= VFF_CURNEDEST; 180 } 181 } 182 } 183 } 184 185 if (lpszFilename && !testFileExistenceA(curDir, lpszFilename, TRUE)) 186 retval |= VFF_FILEINUSE; 267 187 268 188 curDirSizeReq = strlen(curDir) + 1; 269 189 destDirSizeReq = strlen(destDir) + 1; 270 271 272 190 273 191 /* Make sure that the pointers to the size of the buffers are … … 275 193 is valid, then make sure that the buffer pointer is valid, too! */ 276 194 277 if(lpuDestDirLen && lpszDestDir) { 278 if(*lpuDestDirLen < destDirSizeReq) { 279 retval |= VFF_BUFFTOOSMALL; 280 if (*lpuDestDirLen) { 281 lstrcpynA(lpszDestDir, destDir, *lpuDestDirLen); 282 } 283 } 284 else 285 strcpy(lpszDestDir, destDir); 286 287 *lpuDestDirLen = destDirSizeReq; 288 } 289 290 if(lpuCurDirLen && lpszCurDir) { 291 if(*lpuCurDirLen < curDirSizeReq) { 292 retval |= VFF_BUFFTOOSMALL; 293 if (*lpuCurDirLen) { 294 lstrcpynA(lpszCurDir, curDir, *lpuCurDirLen); 295 } 296 } 297 else 298 strcpy(lpszCurDir, curDir); 299 300 *lpuCurDirLen = curDirSizeReq; 301 } 302 303 TRACE("ret = %lu (%s%s%s)\n", retval, 304 (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "", 305 (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "", 306 (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : ""); 307 308 ver_dstring("\t(Exit) lpszCurDir = ", lpszCurDir, ""); 309 if(lpuCurDirLen) 310 TRACE("\t(Exit) lpuCurDirLen = %p (%u)\n", 311 lpuCurDirLen, *lpuCurDirLen); 312 else 313 TRACE("\t(Exit) lpuCurDirLen = (null)\n"); 314 315 ver_dstring("\t(Exit) lpszDestDir = ", lpszDestDir, ""); 316 if(lpuDestDirLen) 317 TRACE("\t(Exit) lpuDestDirLen = %p (%u)\n", 318 lpuDestDirLen, *lpuDestDirLen); 195 if(lpuDestDirLen && lpszDestDir) 196 { 197 if (*lpuDestDirLen < destDirSizeReq) retval |= VFF_BUFFTOOSMALL; 198 lstrcpynA(lpszDestDir, destDir, *lpuDestDirLen); 199 *lpuDestDirLen = destDirSizeReq; 200 } 201 if(lpuCurDirLen && lpszCurDir) 202 { 203 if(*lpuCurDirLen < curDirSizeReq) retval |= VFF_BUFFTOOSMALL; 204 lstrcpynA(lpszCurDir, curDir, *lpuCurDirLen); 205 *lpuCurDirLen = curDirSizeReq; 206 } 207 208 TRACE("ret = %lu (%s%s%s) curdir=%s destdir=%s\n", retval, 209 (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "", 210 (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "", 211 (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : "", 212 debugstr_a(lpszCurDir), debugstr_a(lpszDestDir)); 319 213 320 214 return retval; 321 215 } 322 216 323 /* VerFindFile32W [VERSION.6] */ 324 DWORD WINAPI VerFindFileW( 325 UINT flags,LPCWSTR filename,LPCWSTR windir,LPCWSTR appdir, 326 LPWSTR curdir,UINT *pcurdirlen,LPWSTR destdir,UINT *pdestdirlen ) 217 /***************************************************************************** 218 * VerFindFileW [VERSION.@] 219 */ 220 DWORD WINAPI VerFindFileW( UINT flags,LPCWSTR lpszFilename,LPCWSTR lpszWinDir, 221 LPCWSTR lpszAppDir, LPWSTR lpszCurDir,UINT *lpuCurDirLen, 222 LPWSTR lpszDestDir,UINT *lpuDestDirLen ) 327 223 { 328 UINT curdirlen, destdirlen; 329 LPSTR wfn,wwd,wad,wdd,wcd; 330 DWORD ret; 331 332 wfn = HEAP_strdupWtoA( GetProcessHeap(), 0, filename ); 333 wwd = HEAP_strdupWtoA( GetProcessHeap(), 0, windir ); 334 wad = HEAP_strdupWtoA( GetProcessHeap(), 0, appdir ); 335 wcd = HeapAlloc( GetProcessHeap(), 0, *pcurdirlen ); 336 wdd = HeapAlloc( GetProcessHeap(), 0, *pdestdirlen ); 337 ret = VerFindFileA(flags,wfn,wwd,wad,wcd,&curdirlen,wdd,&destdirlen); 338 lstrcpynAtoW(curdir,wcd,*pcurdirlen); 339 lstrcpynAtoW(destdir,wdd,*pdestdirlen); 340 *pcurdirlen = strlen(wcd); 341 *pdestdirlen = strlen(wdd); 342 HeapFree( GetProcessHeap(), 0, wfn ); 343 HeapFree( GetProcessHeap(), 0, wwd ); 344 HeapFree( GetProcessHeap(), 0, wad ); 345 HeapFree( GetProcessHeap(), 0, wcd ); 346 HeapFree( GetProcessHeap(), 0, wdd ); 347 return ret; 224 static const WCHAR emptyW; 225 DWORD retval = 0; 226 const WCHAR *curDir; 227 const WCHAR *destDir; 228 unsigned int curDirSizeReq; 229 unsigned int destDirSizeReq; 230 WCHAR systemDir[MAX_PATH]; 231 232 /* Print out debugging information */ 233 TRACE("flags = %x filename=%s windir=%s appdir=%s curdirlen=%p(%u) destdirlen=%p(%u)\n", 234 flags, debugstr_w(lpszFilename), debugstr_w(lpszWinDir), debugstr_w(lpszAppDir), 235 lpuCurDirLen, lpuCurDirLen ? *lpuCurDirLen : 0, 236 lpuDestDirLen, lpuDestDirLen ? *lpuDestDirLen : 0 ); 237 238 /* Figure out where the file should go; shared files default to the 239 system directory */ 240 241 GetSystemDirectoryW(systemDir, sizeof(systemDir)/sizeof(WCHAR)); 242 curDir = &emptyW; 243 destDir = &emptyW; 244 245 if(flags & VFFF_ISSHAREDFILE) 246 { 247 destDir = systemDir; 248 /* Were we given a filename? If so, try to find the file. */ 249 if(lpszFilename) 250 { 251 if(testFileExistenceW(destDir, lpszFilename, FALSE)) curDir = destDir; 252 else if(lpszAppDir && testFileExistenceW(lpszAppDir, lpszFilename, FALSE)) 253 { 254 curDir = lpszAppDir; 255 retval |= VFF_CURNEDEST; 256 } 257 } 258 } 259 else /* not a shared file */ 260 { 261 if(lpszAppDir) 262 { 263 destDir = lpszAppDir; 264 if(lpszFilename) 265 { 266 if(testFileExistenceW(destDir, lpszFilename, FALSE)) curDir = destDir; 267 else if(testFileExistenceW(systemDir, lpszFilename, FALSE)) 268 { 269 curDir = systemDir; 270 retval |= VFF_CURNEDEST; 271 } 272 } 273 } 274 } 275 276 if (lpszFilename && !testFileExistenceW(curDir, lpszFilename, TRUE)) 277 retval |= VFF_FILEINUSE; 278 279 curDirSizeReq = strlenW(curDir) + 1; 280 destDirSizeReq = strlenW(destDir) + 1; 281 282 /* Make sure that the pointers to the size of the buffers are 283 valid; if not, do NOTHING with that buffer. If that pointer 284 is valid, then make sure that the buffer pointer is valid, too! */ 285 286 if(lpuDestDirLen && lpszDestDir) 287 { 288 if (*lpuDestDirLen < destDirSizeReq) retval |= VFF_BUFFTOOSMALL; 289 lstrcpynW(lpszDestDir, destDir, *lpuDestDirLen); 290 *lpuDestDirLen = destDirSizeReq; 291 } 292 if(lpuCurDirLen && lpszCurDir) 293 { 294 if(*lpuCurDirLen < curDirSizeReq) retval |= VFF_BUFFTOOSMALL; 295 lstrcpynW(lpszCurDir, curDir, *lpuCurDirLen); 296 *lpuCurDirLen = curDirSizeReq; 297 } 298 299 TRACE("ret = %lu (%s%s%s) curdir=%s destdir=%s\n", retval, 300 (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "", 301 (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "", 302 (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : "", 303 debugstr_w(lpszCurDir), debugstr_w(lpszDestDir)); 304 return retval; 348 305 } 349 306 … … 355 312 356 313 alloclen = 1000; 357 buf= xmalloc(alloclen); 314 buf=HeapAlloc(GetProcessHeap(), 0, alloclen); 315 if(buf == NULL) { 316 WARN("Memory exausted while fetching version info!\n"); 317 return NULL; 318 } 358 319 while (1) { 359 320 ret = GetFileVersionInfoA(fn,0,alloclen,buf); 360 321 if (!ret) { 361 free(buf);362 return 0;322 HeapFree(GetProcessHeap(), 0, buf); 323 return NULL; 363 324 } 364 325 if (alloclen<*(WORD*)buf) { 365 free(buf);366 326 alloclen = *(WORD*)buf; 367 buf = xmalloc(alloclen); 327 HeapFree(GetProcessHeap(), 0, buf); 328 buf = HeapAlloc(GetProcessHeap(), 0, alloclen); 329 if(buf == NULL) { 330 WARN("Memory exausted while fetching version info!\n"); 331 return NULL; 332 } 368 333 } else { 369 334 *vffi = (VS_FIXEDFILEINFO*)(buf+0x14); … … 391 356 392 357 /****************************************************************************** 393 * VerInstallFile 32A [VERSION.7]358 * VerInstallFileA [VERSION.@] 394 359 */ 395 360 DWORD WINAPI VerInstallFileA( … … 413 378 sprintf(destfn,"%s\\%s",pdest,destfilename); 414 379 hfsrc=LZOpenFileA(srcfn,&ofs,OF_READ); 415 if (hfsrc ==HFILE_ERROR)380 if (hfsrc < 0) 416 381 return VIF_CANNOTREADSRC; 417 382 sprintf(tmpfn,"%s\\%s",pdest,destfilename); 418 383 tmplast=strlen(pdest)+1; 419 384 attr = GetFileAttributesA(tmpfn); 420 if (attr !=-1) {385 if (attr != INVALID_FILE_ATTRIBUTES) { 421 386 if (attr & FILE_ATTRIBUTE_READONLY) { 422 387 LZClose(hfsrc); … … 425 390 /* FIXME: check if file currently in use and return VIF_FILEINUSE */ 426 391 } 427 attr = -1;392 attr = INVALID_FILE_ATTRIBUTES; 428 393 if (flags & VIFF_FORCEINSTALL) { 429 394 if (tmpfile[0]) { … … 432 397 attr = GetFileAttributesA(tmpfn); 433 398 /* if it exists, it has been copied by the call before. 434 * we jump over the copy part... 399 * we jump over the copy part... 435 400 */ 436 401 } 437 402 } 438 if (attr == -1) {403 if (attr == INVALID_FILE_ATTRIBUTES) { 439 404 char *s; 440 405 … … 463 428 case LZERROR_BADOUTHANDLE: 464 429 case LZERROR_WRITE: 465 ret = VIF_OUTOF MEMORY; /* FIXME: correct? */430 ret = VIF_OUTOFSPACE; 466 431 break; 467 432 case LZERROR_GLOBALLOC: 468 433 case LZERROR_GLOBLOCK: 469 ret = VIF_OUTOF SPACE;434 ret = VIF_OUTOFMEMORY; 470 435 break; 471 436 default: /* unknown error, should not happen */ … … 506 471 VerQueryValueA(buf2,"\\VarFileInfo\\Translation",(LPVOID*)&tbuf2,&len2) 507 472 ) { 508 /* irgendwas mit tbuf1 und tbuf2 machen 473 /* irgendwas mit tbuf1 und tbuf2 machen 509 474 * generiert DIFFLANG|MISMATCH 510 475 */ 511 476 } 512 free(buf2);477 HeapFree(GetProcessHeap(), 0, buf2); 513 478 } else 514 479 xret=VIF_MISMATCH|VIF_SRCOLD; 515 free(buf1);480 HeapFree(GetProcessHeap(), 0, buf1); 516 481 } 517 482 } … … 533 498 return xret; 534 499 } 535 if ((!(flags & VIFF_DONTDELETEOLD)) && 536 curdir && 500 if ((!(flags & VIFF_DONTDELETEOLD)) && 501 curdir && 537 502 *curdir && 538 503 lstrcmpiA(curdir,pdest) … … 541 506 542 507 sprintf(curfn,"%s\\%s",curdir,destfilename); 543 if ( -1!=GetFileAttributesA(curfn)) {508 if (INVALID_FILE_ATTRIBUTES != GetFileAttributesA(curfn)) { 544 509 /* FIXME: check if in use ... if it is, VIF_CANNOTDELETECUR */ 545 510 if (!DeleteFileA(curfn)) … … 557 522 558 523 559 /* VerInstallFile32W [VERSION.8] */ 524 /****************************************************************************** 525 * VerInstallFileW [VERSION.@] 526 */ 560 527 DWORD WINAPI VerInstallFileW( 561 528 UINT flags,LPCWSTR srcfilename,LPCWSTR destfilename,LPCWSTR srcdir, 562 529 LPCWSTR destdir,LPCWSTR curdir,LPWSTR tmpfile,UINT *tmpfilelen ) 563 530 { 564 LPSTR wsrcf ,wsrcd,wdestf,wdestd,wtmpf,wcurd;531 LPSTR wsrcf = NULL, wsrcd = NULL, wdestf = NULL, wdestd = NULL, wtmpf = NULL, wcurd = NULL; 565 532 DWORD ret; 566 567 wsrcf = HEAP_strdupWtoA( GetProcessHeap(), 0, srcfilename ); 568 wsrcd = HEAP_strdupWtoA( GetProcessHeap(), 0, srcdir ); 569 wdestf = HEAP_strdupWtoA( GetProcessHeap(), 0, destfilename ); 570 wdestd = HEAP_strdupWtoA( GetProcessHeap(), 0, destdir ); 571 wtmpf = HEAP_strdupWtoA( GetProcessHeap(), 0, tmpfile ); 572 wcurd = HEAP_strdupWtoA( GetProcessHeap(), 0, curdir ); 573 ret = VerInstallFileA(flags,wsrcf,wdestf,wsrcd,wdestd,wcurd,wtmpf,tmpfilelen); 533 UINT len; 534 535 if (srcfilename) 536 { 537 len = WideCharToMultiByte( CP_ACP, 0, srcfilename, -1, NULL, 0, NULL, NULL ); 538 if ((wsrcf = HeapAlloc( GetProcessHeap(), 0, len ))) 539 WideCharToMultiByte( CP_ACP, 0, srcfilename, -1, wsrcf, len, NULL, NULL ); 540 } 541 if (srcdir) 542 { 543 len = WideCharToMultiByte( CP_ACP, 0, srcdir, -1, NULL, 0, NULL, NULL ); 544 if ((wsrcd = HeapAlloc( GetProcessHeap(), 0, len ))) 545 WideCharToMultiByte( CP_ACP, 0, srcdir, -1, wsrcd, len, NULL, NULL ); 546 } 547 if (destfilename) 548 { 549 len = WideCharToMultiByte( CP_ACP, 0, destfilename, -1, NULL, 0, NULL, NULL ); 550 if ((wdestf = HeapAlloc( GetProcessHeap(), 0, len ))) 551 WideCharToMultiByte( CP_ACP, 0, destfilename, -1, wdestf, len, NULL, NULL ); 552 } 553 if (destdir) 554 { 555 len = WideCharToMultiByte( CP_ACP, 0, destdir, -1, NULL, 0, NULL, NULL ); 556 if ((wdestd = HeapAlloc( GetProcessHeap(), 0, len ))) 557 WideCharToMultiByte( CP_ACP, 0, destdir, -1, wdestd, len, NULL, NULL ); 558 } 559 if (curdir) 560 { 561 len = WideCharToMultiByte( CP_ACP, 0, curdir, -1, NULL, 0, NULL, NULL ); 562 if ((wcurd = HeapAlloc( GetProcessHeap(), 0, len ))) 563 WideCharToMultiByte( CP_ACP, 0, curdir, -1, wcurd, len, NULL, NULL ); 564 } 565 len = *tmpfilelen * sizeof(WCHAR); 566 wtmpf = HeapAlloc( GetProcessHeap(), 0, len ); 567 ret = VerInstallFileA(flags,wsrcf,wdestf,wsrcd,wdestd,wcurd,wtmpf,&len); 574 568 if (!ret) 575 lstrcpynAtoW(tmpfile,wtmpf,*tmpfilelen); 569 *tmpfilelen = MultiByteToWideChar( CP_ACP, 0, wtmpf, -1, tmpfile, *tmpfilelen ); 570 else if (ret & VIF_BUFFTOOSMALL) 571 *tmpfilelen = len; /* FIXME: not correct */ 572 576 573 HeapFree( GetProcessHeap(), 0, wsrcf ); 577 574 HeapFree( GetProcessHeap(), 0, wsrcd ); … … 579 576 HeapFree( GetProcessHeap(), 0, wdestd ); 580 577 HeapFree( GetProcessHeap(), 0, wtmpf ); 581 if (wcurd) 582 HeapFree( GetProcessHeap(), 0, wcurd ); 578 HeapFree( GetProcessHeap(), 0, wcurd ); 583 579 return ret; 584 580 } 585
Note:
See TracChangeset
for help on using the changeset viewer.