Alexandre Julliard : msi: Create temp files in the destination directory instead of the root.
Alexandre Julliard
julliard at winehq.org
Thu Jun 9 11:47:39 CDT 2011
Module: wine
Branch: master
Commit: 89472db9e3bc755427be98b7a7848c7480ec869d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=89472db9e3bc755427be98b7a7848c7480ec869d
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Jun 9 15:56:57 2011 +0200
msi: Create temp files in the destination directory instead of the root.
---
dlls/msi/files.c | 25 ++++++++++++++-----------
dlls/msi/media.c | 28 ++++++++++++++++------------
2 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index af84e9b..94e5e6c 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -195,23 +195,25 @@ static UINT copy_install_file(MSIPACKAGE *package, MSIFILE *file, LPWSTR source)
}
if (gle == ERROR_SHARING_VIOLATION || gle == ERROR_USER_MAPPED_FILE)
{
- WCHAR tmpfileW[MAX_PATH], *pathW, *p;
+ WCHAR *tmpfileW, *pathW, *p;
DWORD len;
TRACE("file in use, scheduling rename operation\n");
- GetTempFileNameW(szBackSlash, szMsi, 0, tmpfileW);
- len = strlenW(file->TargetPath) + strlenW(tmpfileW) + 1;
- if (!(pathW = msi_alloc(len * sizeof(WCHAR))))
- return ERROR_OUTOFMEMORY;
-
- strcpyW(pathW, file->TargetPath);
+ if (!(pathW = strdupW( file->TargetPath ))) return ERROR_OUTOFMEMORY;
if ((p = strrchrW(pathW, '\\'))) *p = 0;
- strcatW(pathW, tmpfileW);
+ len = strlenW( pathW ) + 16;
+ if (!(tmpfileW = msi_alloc(len * sizeof(WCHAR))))
+ {
+ msi_free( pathW );
+ return ERROR_OUTOFMEMORY;
+ }
+ if (!GetTempFileNameW( pathW, szMsi, 0, tmpfileW )) tmpfileW[0] = 0;
+ msi_free( pathW );
- if (CopyFileW(source, pathW, FALSE) &&
+ if (CopyFileW(source, tmpfileW, FALSE) &&
MoveFileExW(file->TargetPath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT) &&
- MoveFileExW(pathW, file->TargetPath, MOVEFILE_DELAY_UNTIL_REBOOT))
+ MoveFileExW(tmpfileW, file->TargetPath, MOVEFILE_DELAY_UNTIL_REBOOT))
{
file->state = msifs_installed;
package->need_reboot = 1;
@@ -221,8 +223,9 @@ static UINT copy_install_file(MSIPACKAGE *package, MSIFILE *file, LPWSTR source)
{
gle = GetLastError();
WARN("failed to schedule rename operation: %d)\n", gle);
+ DeleteFileW( tmpfileW );
}
- msi_free(pathW);
+ msi_free(tmpfileW);
}
return gle;
diff --git a/dlls/msi/media.c b/dlls/msi/media.c
index 9de2566..9f29ef7 100644
--- a/dlls/msi/media.c
+++ b/dlls/msi/media.c
@@ -458,32 +458,36 @@ static INT_PTR cabinet_copy_file(FDINOTIFICATIONTYPE fdint,
}
if (err == ERROR_SHARING_VIOLATION || err == ERROR_USER_MAPPED_FILE)
{
- WCHAR tmpfileW[MAX_PATH], *tmppathW, *p;
+ WCHAR *tmpfileW, *tmppathW, *p;
DWORD len;
TRACE("file in use, scheduling rename operation\n");
- GetTempFileNameW(szBackSlash, szMsi, 0, tmpfileW);
- len = strlenW(path) + strlenW(tmpfileW) + 1;
- if (!(tmppathW = msi_alloc(len * sizeof(WCHAR))))
- return ERROR_OUTOFMEMORY;
-
- strcpyW(tmppathW, path);
+ if (!(tmppathW = strdupW( path ))) return ERROR_OUTOFMEMORY;
if ((p = strrchrW(tmppathW, '\\'))) *p = 0;
- strcatW(tmppathW, tmpfileW);
+ len = strlenW( tmppathW ) + 16;
+ if (!(tmpfileW = msi_alloc(len * sizeof(WCHAR))))
+ {
+ msi_free( tmppathW );
+ return ERROR_OUTOFMEMORY;
+ }
+ if (!GetTempFileNameW(tmppathW, szMsi, 0, tmpfileW)) tmpfileW[0] = 0;
+ msi_free( tmppathW );
- handle = CreateFileW(tmppathW, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, attrs, NULL);
+ handle = CreateFileW(tmpfileW, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, attrs, NULL);
if (handle != INVALID_HANDLE_VALUE &&
MoveFileExW(path, NULL, MOVEFILE_DELAY_UNTIL_REBOOT) &&
- MoveFileExW(tmppathW, path, MOVEFILE_DELAY_UNTIL_REBOOT))
+ MoveFileExW(tmpfileW, path, MOVEFILE_DELAY_UNTIL_REBOOT))
{
data->package->need_reboot = 1;
}
else
+ {
WARN("failed to schedule rename operation %s (error %d)\n", debugstr_w(path), GetLastError());
-
- msi_free(tmppathW);
+ DeleteFileW( tmpfileW );
+ }
+ msi_free(tmpfileW);
}
else
WARN("failed to create %s (error %d)\n", debugstr_w(path), err);
More information about the wine-cvs
mailing list