comparison cinst/nssstore_win.c @ 502:e551de11d8b6

Properly handle the case that the file does not exist. TRUNCATE makes create file fail if the file does not exist but we need TRUNCATE in the case that the file already exists
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 28 Apr 2014 09:18:07 +0000
parents a9da8e4eeff7
children 7f2cb85288d0
comparison
equal deleted inserted replaced
501:f925ddfe6301 502:e551de11d8b6
478 NULL, /* use the security attributes from the folder */ 478 NULL, /* use the security attributes from the folder */
479 OPEN_ALWAYS | TRUNCATE_EXISTING, 479 OPEN_ALWAYS | TRUNCATE_EXISTING,
480 0, 480 0,
481 NULL); 481 NULL);
482 482
483 if (hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_NOT_FOUND)
484 {
485 hFile = CreateFileW(path,
486 GENERIC_WRITE,
487 0, /* don't share */
488 NULL, /* use the security attributes from the folder */
489 CREATE_NEW,
490 0,
491 NULL);
492 }
483 if (hFile == INVALID_HANDLE_VALUE) 493 if (hFile == INVALID_HANDLE_VALUE)
484 { 494 {
485 ERRORPRINTF ("Failed to create file\n"); 495 PRINTLASTERROR ("Failed to create file\n");
486 xfree(path); 496 xfree(path);
487 return NULL; 497 return NULL;
488 } 498 }
489 if (!write_instructions (to_install, hFile, false)) 499 if (!write_instructions (to_install, hFile, false))
490 { 500 {

http://wald.intevation.org/projects/trustbridge/