mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
** WIP ** SETUPAPI: Improve do_file_copyW: Generate a temporary file path based on the target path (thus, ensured to be writable)
Needed because we may run setupapi to extract and copy files to a writable target directory, from a read-only ReactOS installation (e.g. livecd)
This commit is contained in:
parent
2a993c03db
commit
2d6a0e69ef
1 changed files with 10 additions and 10 deletions
|
@ -1237,6 +1237,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
INT hSource, hTemp;
|
INT hSource, hTemp;
|
||||||
OFSTRUCT OfStruct;
|
OFSTRUCT OfStruct;
|
||||||
|
PWSTR pTmpFile;
|
||||||
WCHAR TempPath[MAX_PATH];
|
WCHAR TempPath[MAX_PATH];
|
||||||
WCHAR TempFile[MAX_PATH];
|
WCHAR TempFile[MAX_PATH];
|
||||||
LONG lRes;
|
LONG lRes;
|
||||||
|
@ -1246,22 +1247,21 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
||||||
TRACE("copy %s to %s style 0x%lx\n",debugstr_w(source),debugstr_w(target),style);
|
TRACE("copy %s to %s style 0x%lx\n",debugstr_w(source),debugstr_w(target),style);
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
/* Get a temp file name */
|
/* Generate a temporary file path and name based on the target path */
|
||||||
if (!GetTempPathW(ARRAYSIZE(TempPath), TempPath))
|
wcsncpy(TempPath, target, ARRAYSIZE(TempPath));
|
||||||
{
|
TempPath[ARRAYSIZE(TempPath) - 1] = UNICODE_NULL;
|
||||||
ERR("GetTempPathW error\n");
|
pTmpFile = (PWSTR)pSetupGetFileTitle(TempPath); // Remove the file name
|
||||||
return FALSE;
|
*pTmpFile = UNICODE_NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* Try to open the source file */
|
/* Try to open the source file */
|
||||||
hSource = LZOpenFileW((LPWSTR)source, &OfStruct, OF_READ);
|
hSource = LZOpenFileW((LPWSTR)source, &OfStruct, OF_READ);
|
||||||
if (hSource < 0)
|
if (hSource < 0)
|
||||||
{
|
{
|
||||||
TRACE("LZOpenFileW(1) error %d %s\n", (int)hSource, debugstr_w(source));
|
TRACE("LZOpenFileW(1) error %d (%s)\n", hSource, debugstr_w(source));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GetTempFileNameW(TempPath, L"", 0, TempFile))
|
if (!GetTempFileNameW(TempPath, L"SET", 0, TempFile))
|
||||||
{
|
{
|
||||||
dwLastError = GetLastError();
|
dwLastError = GetLastError();
|
||||||
|
|
||||||
|
@ -1282,7 +1282,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
||||||
{
|
{
|
||||||
dwLastError = GetLastError();
|
dwLastError = GetLastError();
|
||||||
|
|
||||||
ERR("LZOpenFileW(2) error %d %s\n", (int)hTemp, debugstr_w(TempFile));
|
ERR("LZOpenFileW(2) error %d (%s)\n", hTemp, debugstr_w(TempFile));
|
||||||
|
|
||||||
/* Close the source handle */
|
/* Close the source handle */
|
||||||
LZClose(hSource);
|
LZClose(hSource);
|
||||||
|
@ -1305,7 +1305,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
||||||
|
|
||||||
if (lRes < 0)
|
if (lRes < 0)
|
||||||
{
|
{
|
||||||
ERR("LZCopy error %d (%s, %s)\n", (int)lRes, debugstr_w(source), debugstr_w(TempFile));
|
ERR("LZCopy error %d (%s, %s)\n", lRes, debugstr_w(source), debugstr_w(TempFile));
|
||||||
|
|
||||||
/* Delete temp file if copy was not successful */
|
/* Delete temp file if copy was not successful */
|
||||||
DeleteFileW(TempFile);
|
DeleteFileW(TempFile);
|
||||||
|
|
Loading…
Reference in a new issue